Project

General

Profile

Feature #16144 ยป 0001-Honor-Logger-level-overrides-in-Logger-add.patch

georgeclaghorn (George Claghorn), 09/05/2019 12:55 AM

View differences:

lib/logger.rb
# Returns +true+ iff the current severity level allows for the printing of
# +DEBUG+ messages.
def debug?; @level <= DEBUG; end
def debug?; level <= DEBUG; end
# Sets the severity to DEBUG.
def debug!; self.level = DEBUG; end
# Returns +true+ iff the current severity level allows for the printing of
# +INFO+ messages.
def info?; @level <= INFO; end
def info?; level <= INFO; end
# Sets the severity to INFO.
def info!; self.level = INFO; end
# Returns +true+ iff the current severity level allows for the printing of
# +WARN+ messages.
def warn?; @level <= WARN; end
def warn?; level <= WARN; end
# Sets the severity to WARN.
def warn!; self.level = WARN; end
# Returns +true+ iff the current severity level allows for the printing of
# +ERROR+ messages.
def error?; @level <= ERROR; end
def error?; level <= ERROR; end
# Sets the severity to ERROR.
def error!; self.level = ERROR; end
# Returns +true+ iff the current severity level allows for the printing of
# +FATAL+ messages.
def fatal?; @level <= FATAL; end
def fatal?; level <= FATAL; end
# Sets the severity to FATAL.
def fatal!; self.level = FATAL; end
......
#
def add(severity, message = nil, progname = nil)
severity ||= UNKNOWN
if @logdev.nil? or severity < @level
if @logdev.nil? or severity < level
return true
end
if progname.nil?
test/logger/test_logger.rb
r.close
assert_equal("msg2\n\n", msg)
end
class CustomLogger < Logger
def level
INFO
end
end
def test_overriding_level
logger = CustomLogger.new(nil)
log = log(logger, :info) { "msg" }
assert_equal "msg\n", log.msg
#
log = log(logger, :debug) { "msg" }
assert_nil log.msg
end
end
    (1-1/1)