Class: Swoop::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/swoop/formatter.rb

Instance Method Summary collapse

Instance Method Details

#call(severity, datetime, progname, msg) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/swoop/formatter.rb', line 3

def call(severity, datetime, progname, msg)
  if Swoop.colorize?
    "#{ severity[0].bold.send(severity_color(severity)) } #{ datetime.iso8601.bold.black } #{ (progname || "app").bold }: #{ msg.strip }\n"
  else
    "#{ severity[0] } #{ datetime.iso8601 } #{ progname || "rails" }: #{ msg.strip }\n"
  end
end

#severity_color(severity) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/swoop/formatter.rb', line 11

def severity_color(severity)
  case severity
  when "DEBUG" then :black
  when "INFO" then :blue
  when "WARN" then :yellow
  when "ERROR" then :red
  when "FATAL" then :red
  else :black
  end
end