1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/syslog/lib/syslog/logger.rb: add a formatter to the

Syslog::Logger object. [Bug #7065]
* test/syslog/test_syslog_logger.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2012-09-27 09:20:58 +00:00
parent 015af597e0
commit e0bff65092
3 changed files with 50 additions and 14 deletions

View file

@ -29,7 +29,7 @@ class TestSyslogRootLogger < Test::Unit::TestCase
end
def log(level, format, *args)
@line = "#{LEVEL_LABEL_MAP[level]} - \#{format % args}"
@line = "#{LEVEL_LABEL_MAP[level]} - #{format % args}"
end
attr_reader :line
@ -92,6 +92,16 @@ class TestSyslogRootLogger < Test::Unit::TestCase
assert_equal Logger::DEBUG, @logger.level
end
def test_custom_formatter
@logger.formatter = Class.new {
def call severity, time, progname, msg
"hi mom!"
end
}.new
assert_match(/hi mom!/, log_raw(:fatal, 'fatal level message'))
end
def test_add
msg = log_add nil, 'unknown level message' # nil == unknown
assert_equal LEVEL_LABEL_MAP[Logger::UNKNOWN], msg.severity