diff options
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/buffered_logger.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb index a14f008be5..b937d4c50d 100644 --- a/activesupport/lib/active_support/buffered_logger.rb +++ b/activesupport/lib/active_support/buffered_logger.rb @@ -48,14 +48,17 @@ module ActiveSupport if log.respond_to?(:write) @log = log elsif File.exist?(log) - @log = open(log, (File::WRONLY | File::APPEND)) - @log.binmode - @log.sync = true + @log = open_log(log, (File::WRONLY | File::APPEND)) else FileUtils.mkdir_p(File.dirname(log)) - @log = open(log, (File::WRONLY | File::APPEND | File::CREAT)) - @log.binmode - @log.sync = true + @log = open_log(log, (File::WRONLY | File::APPEND | File::CREAT)) + end + end + + def open_log(log, mode) + open(log, mode).tap do |log| + log.set_encoding(Encoding::BINARY) if log.respond_to?(:set_encoding) + log.sync = true end end |