Skip to content
Browse files
logger.rb: Fix handling progname
Because progname was memoized with ||= a logger call that involved
outputting false would be nil. Example code:

  logger =  # => nil

Perform an explicit nil check instead of ||= so that false will be output.

patched by Gavin Miller <> [Fix GH-1667]

git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
sonots committed Jul 20, 2017
1 parent 1da6483 commit 93fe0ff2f1a2818523799d3da68cade115bec783
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
@@ -457,7 +457,9 @@ def add(severity, message = nil, progname = nil)
if @logdev.nil? or severity < @level
return true
progname ||= @progname
if progname.nil?
progname = @progname
if message.nil?
if block_given?
message = yield
@@ -235,6 +235,10 @@ def test_add
log = log_add(logger, WARN, nil, "progname?")
assert_equal("progname?\n", log.msg)
assert_equal("my_progname", log.progname)
logger =
log = log_add(logger, INFO, nil, false)
assert_equal("false\n", log.msg)

def test_level_log

0 comments on commit 93fe0ff

Please sign in to comment.