class Wright::Logger::Formatter
@api private Default formatter for Wright
log messages.
Public Instance Methods
call(severity, _time, _progname, message)
click to toggle source
This method is called by {Wright::Logger} to format log messages.
@param severity [String] the log entry's severity @param _time [Time] the log entry's time stamp (ignored) @param _progname [String] the log entry's program name (ignored) @param message [String] the log message
@return [String] the formatted log entry
# File lib/wright/logger.rb, line 21 def call(severity, _time, _progname, message) log_entry = "#{severity}: #{message}\n" if Wright::Config[:log][:colorize] colorize(log_entry, severity) else log_entry end end
Private Instance Methods
colorize(string, severity)
click to toggle source
ANSI-Colorizes a log message according to its severity.
@param string [String] the log message to be colorized @param severity [String] the severity of the log message
@return [String] the colorized log message
# File lib/wright/logger.rb, line 38 def colorize(string, severity) case severity when 'ERROR', 'FATAL' Wright::Util::Color.red(string) when 'WARN' Wright::Util::Color.yellow(string) when 'INFO' string else string end end