mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
set log encoding to BINARY, but still use text mode to output portable newlines
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user