class CerberusUtils::DefaultLogger
Instantiated by the Log
singleton can be replaced by the user provided the Logger supports the four log level outputs
Public Class Methods
new()
click to toggle source
Init the default logger
# File lib/cerberus_utils/default_logger.rb, line 15 def initialize @logger = Logger.new STDOUT # log level should be configurable @logger.level = Logger::DEBUG @logger.formatter = proc do |severity, datetime, progname, msg| severityFormatted = case severity when "ERROR" "\e[31m#{severity}\e[0m" when "WARN" "\e[33m#{severity}\e[0m" when "DEBUG" "\e[37m#{severity}\e[0m" else "#{severity}" end "#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')} #{severityFormatted}: #{msg}\n" end end
Public Instance Methods
debug(msg)
click to toggle source
Log
a debug message to the default logger
# File lib/cerberus_utils/default_logger.rb, line 60 def debug(msg) @logger.debug(msg) end
error(msg)
click to toggle source
Log
a error message to the default logger
# File lib/cerberus_utils/default_logger.rb, line 39 def error(msg) @logger.error(msg) end
info(msg)
click to toggle source
Log
a info message to the default logger
# File lib/cerberus_utils/default_logger.rb, line 53 def info(msg) @logger.info(msg) end
warn(msg)
click to toggle source
Log
a warning message to the default logger
# File lib/cerberus_utils/default_logger.rb, line 46 def warn(msg) @logger.warn(msg) end