Class: ActiveSupport::Logger::SimpleFormatter
- Inherits:
-
Object
- Object
- ActiveSupport::Logger::SimpleFormatter
- Defined in:
- lib/colored_logger.rb
Constant Summary collapse
- SEVERITY_TO_COLOR_MAP =
{ 'DEBUG'=>"#{COLORS[:reset]};#{COLORS[:white]};#{BGCOLORS[:magenta]};#{EXTRAS[:bold]}", 'INFO'=>"#{COLORS[:green]}", 'WARN'=>"#{COLORS[:yellow]}", 'ERROR'=>";#{COLORS[:magenta]};#{BGCOLORS[:white]}", 'FATAL'=>";#{COLORS[:red]}", 'UNKNOWN'=>"#{COLORS[:white]}" }
Instance Method Summary collapse
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/colored_logger.rb', line 51 def call(severity, time, progname, msg) formatted_severity = sprintf("%-4s",severity) formatted_time = time.strftime("%Y-%m-%d %H:%M:%S.") << time.usec.to_s[0..2].rjust(3) color = SEVERITY_TO_COLOR_MAP[severity] "\033[0;37m#{formatted_time}\033[0m [\033[#{color}m#{formatted_severity}\033[0m] #{msg.strip} (pid:#{$$})\n" end |