Sha256: dd06b69ec4392113502473127d2efa0ab10f1940f92bd478f688912b57b46ddb
Contents?: true
Size: 967 Bytes
Versions: 19
Compression:
Stored size: 967 Bytes
Contents
module Lita # Creates a Logger with the proper configuration. module Logger class << self # Creates a new {::Logger} outputting to standard error with the given # severity level and a custom format. # @param level [Symbol, String] The name of the log level to use. # @return [::Logger] The {::Logger} object. def get_logger(level) logger = ::Logger.new(STDERR) logger.level = get_level_constant(level) logger.formatter = proc do |severity, datetime, progname, msg| "[#{datetime.utc}] #{severity}: #{msg}\n" end logger end private # Gets the Logger constant for the given severity level. def get_level_constant(level) if level begin ::Logger.const_get(level.to_s.upcase) rescue NameError return ::Logger::INFO end else ::Logger::INFO end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems