class FPM::Scriptable::Log::LogHandler::LogFormatter
Attributes
color[RW]
Public Instance Methods
call(severity, timestamp, progname, msg)
click to toggle source
# File lib/fpm/scriptable/log.rb, line 158 def call(severity, timestamp, progname, msg) c = get_color severity f_severity = sprintf("%-5s", severity.to_s) f_time = timestamp.strftime("%Y-%m-%d %H:%M:%S") if !@color.nil? && @color "\e[#{c}\e[30m[#{f_severity} #{f_time}] #{msg.to_s.strip}\e[0m\n" else "[#{f_severity} #{f_time}] #{msg.to_s.strip}\n" end end
get_color(c)
click to toggle source
# File lib/fpm/scriptable/log.rb, line 171 def get_color(c) case c when 'DEBUG' '46m' when 'WARN' '43m' when 'ERROR' '41m' when 'FATAL' '41m' else '42m' end end