mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/logger] Let File::NULL ("/dev/null", "NUL" etc.) be considered a nil log device
https://github.com/ruby/logger/commit/b42a1b99aa
This commit is contained in:
parent
13baa2b5a5
commit
f3e12caa08
2 changed files with 6 additions and 1 deletions
|
@ -385,7 +385,7 @@ class Logger
|
||||||
self.datetime_format = datetime_format
|
self.datetime_format = datetime_format
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
@logdev = nil
|
@logdev = nil
|
||||||
if logdev
|
if logdev && logdev != File::NULL
|
||||||
@logdev = LogDevice.new(logdev, shift_age: shift_age,
|
@logdev = LogDevice.new(logdev, shift_age: shift_age,
|
||||||
shift_size: shift_size,
|
shift_size: shift_size,
|
||||||
shift_period_suffix: shift_period_suffix,
|
shift_period_suffix: shift_period_suffix,
|
||||||
|
|
|
@ -378,4 +378,9 @@ class TestLogger < Test::Unit::TestCase
|
||||||
log = log(logger, :debug) { "msg" }
|
log = log(logger, :debug) { "msg" }
|
||||||
assert_nil log.msg
|
assert_nil log.msg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_does_not_instantiate_log_device_for_File_NULL
|
||||||
|
l = Logger.new(File::NULL)
|
||||||
|
assert_nil(l.instance_variable_get(:@logdev))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue