logger.rb: Fix handling progname
Because progname was memoized with ||= a logger call that involved outputting false would be nil. Example code: logger = Logger.new(STDOUT) logger.info(false) # => nil Perform an explicit nil check instead of ||= so that false will be output. patched by Gavin Miller <gavingmiller@gmail.com> [Fix GH-1667] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1da648310d
commit
93fe0ff2f1
@ -457,7 +457,9 @@ class Logger
|
||||
if @logdev.nil? or severity < @level
|
||||
return true
|
||||
end
|
||||
progname ||= @progname
|
||||
if progname.nil?
|
||||
progname = @progname
|
||||
end
|
||||
if message.nil?
|
||||
if block_given?
|
||||
message = yield
|
||||
|
@ -235,6 +235,10 @@ class TestLogger < Test::Unit::TestCase
|
||||
log = log_add(logger, WARN, nil, "progname?")
|
||||
assert_equal("progname?\n", log.msg)
|
||||
assert_equal("my_progname", log.progname)
|
||||
#
|
||||
logger = Logger.new(nil)
|
||||
log = log_add(logger, INFO, nil, false)
|
||||
assert_equal("false\n", log.msg)
|
||||
end
|
||||
|
||||
def test_level_log
|
||||
|
Loading…
x
Reference in New Issue
Block a user