ruby-changes:61673
From: Lourens <ko1@a...>
Date: Thu, 11 Jun 2020 14:23:57 +0900 (JST)
Subject: [ruby-changes:61673] ae93ebae67 (master): [ruby/logger] Let Logger#reopen not raise on nil log devices
https://git.ruby-lang.org/ruby.git/commit/?id=ae93ebae67 From ae93ebae677f685aab155d7982c64c1cb6e4b69c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= <lourens@b...> Date: Sat, 28 Mar 2020 16:16:00 +0000 Subject: [ruby/logger] Let Logger#reopen not raise on nil log devices https://github.com/ruby/logger/commit/da7bf844e5 diff --git a/lib/logger.rb b/lib/logger.rb index 4000dae..854687c 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -410,7 +410,7 @@ class Logger https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L410 # Reopen a log device. # def reopen(logdev = nil) - @logdev.reopen(logdev) + @logdev&.reopen(logdev) self end diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index f8cc2e5..4bbfd52 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -216,6 +216,13 @@ class TestLogger < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/logger/test_logger.rb#L216 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" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/