зеркало из https://github.com/github/ruby.git
[ruby/logger] Let Logger#reopen not raise on nil log devices
https://github.com/ruby/logger/commit/da7bf844e5
This commit is contained in:
Родитель
f3e12caa08
Коммит
ae93ebae67
|
@ -410,7 +410,7 @@ class Logger
|
|||
# Reopen a log device.
|
||||
#
|
||||
def reopen(logdev = nil)
|
||||
@logdev.reopen(logdev)
|
||||
@logdev&.reopen(logdev)
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -216,6 +216,13 @@ class TestLogger < Test::Unit::TestCase
|
|||
assert_equal(STDOUT, logger.instance_variable_get(:@logdev).dev)
|
||||
end
|
||||
|
||||
def test_reopen_nil_logdevice
|
||||
logger = Logger.new(File::NULL)
|
||||
assert_nothing_raised do
|
||||
logger.reopen(STDOUT)
|
||||
end
|
||||
end
|
||||
|
||||
def test_add
|
||||
logger = Logger.new(nil)
|
||||
logger.progname = "my_progname"
|
||||
|
|
Загрузка…
Ссылка в новой задаче