mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Honor Syslog::Logger#level overrides
This commit is contained in:
parent
f5e8d33761
commit
31339ef4f2
Notes:
git
2019-09-27 07:02:06 +09:00
2 changed files with 17 additions and 2 deletions
|
@ -112,7 +112,7 @@ class Syslog::Logger
|
|||
end
|
||||
|
||||
def #{meth}?
|
||||
@level <= #{level}
|
||||
level <= #{level}
|
||||
end
|
||||
EOM
|
||||
end
|
||||
|
@ -202,7 +202,7 @@ class Syslog::Logger
|
|||
|
||||
def add severity, message = nil, progname = nil, &block
|
||||
severity ||= ::Logger::UNKNOWN
|
||||
@level <= severity and
|
||||
level <= severity and
|
||||
@@syslog.log( (LEVEL_MAP[severity] | @facility), '%s', formatter.call(severity, Time.now, progname, (message || block.call)) )
|
||||
true
|
||||
end
|
||||
|
|
|
@ -551,6 +551,21 @@ class TestSyslogLogger < TestSyslogRootLogger
|
|||
assert_equal facility|Syslog::LOG_DEBUG, msg.priority
|
||||
end
|
||||
|
||||
class CustomSyslogLogger < Syslog::Logger
|
||||
def level
|
||||
Logger::INFO
|
||||
end
|
||||
end
|
||||
|
||||
def test_overriding_level
|
||||
@logger = CustomSyslogLogger.new
|
||||
log = log_add Logger::INFO, 'msg'
|
||||
assert_equal 'msg', log.msg
|
||||
|
||||
log = log_add Logger::DEBUG, 'msg'
|
||||
assert_nil log.msg
|
||||
end
|
||||
|
||||
end if defined?(Syslog)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue