Feature #12224 ยป 0001-lib-logger.rb-allow-specifying-log-level-via-Logger..patch
lib/logger.rb | ||
---|---|---|
# :call-seq:
|
||
# Logger.new(logdev, shift_age = 7, shift_size = 1048576)
|
||
# Logger.new(logdev, shift_age = 'weekly')
|
||
# Logger.new(logdev, level: :info)
|
||
#
|
||
# === Args
|
||
#
|
||
... | ... | |
# +weekly+ or +monthly+).
|
||
# +shift_size+::
|
||
# Maximum logfile size (only applies when +shift_age+ is a number).
|
||
# +level+::
|
||
# The minimal severity level to log. Defaults to DEBUG.
|
||
#
|
||
# === Description
|
||
#
|
||
# Create an instance.
|
||
#
|
||
def initialize(logdev, shift_age = 0, shift_size = 1048576)
|
||
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG)
|
||
@progname = nil
|
||
@level = DEBUG
|
||
@default_formatter = Formatter.new
|
||
@formatter = nil
|
||
@logdev = nil
|
||
if logdev
|
||
@logdev = LogDevice.new(logdev, :shift_age => shift_age,
|
||
:shift_size => shift_size)
|
||
@logdev = LogDevice.new(logdev, shift_age: shift_age, shift_size: shift_size)
|
||
end
|
||
self.level = level
|
||
end
|
||
#
|
test/logger/test_logger.rb | ||
---|---|---|
r.close
|
||
assert_equal("msg2\n\n", msg)
|
||
end
|
||
def test_initialize_specify_level
|
||
logger = Logger.new(STDERR) # default value
|
||
assert_equal(Logger::DEBUG, logger.level)
|
||
logger = Logger.new(STDERR, level: :info)
|
||
assert_equal(Logger::INFO, logger.level)
|
||
end
|
||
end
|