Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

set log encoding to BINARY, but still use text mode to output portabl…

…e newlines
  • Loading branch information...
commit a37ae63969c766dcbc7898544de3745227a3130b 1 parent 78f855c
Xavier Noria authored
15  activesupport/lib/active_support/buffered_logger.rb
@@ -48,14 +48,17 @@ def initialize(log, level = DEBUG)
48 48
       if log.respond_to?(:write)
49 49
         @log = log
50 50
       elsif File.exist?(log)
51  
-        @log = open(log, (File::WRONLY | File::APPEND))
52  
-        @log.binmode
53  
-        @log.sync = true
  51
+        @log = open_log(log, (File::WRONLY | File::APPEND))
54 52
       else
55 53
         FileUtils.mkdir_p(File.dirname(log))
56  
-        @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
57  
-        @log.binmode
58  
-        @log.sync = true
  54
+        @log = open_log(log, (File::WRONLY | File::APPEND | File::CREAT))
  55
+      end
  56
+    end
  57
+
  58
+    def open_log(log, mode)
  59
+      open(log, mode).tap do |log|
  60
+        log.set_encoding(Encoding::BINARY) if log.respond_to?(:set_encoding)
  61
+        log.sync = true
59 62
       end
60 63
     end
61 64
 

0 notes on commit a37ae63

Please sign in to comment.
Something went wrong with that request. Please try again.