Class: Trooper::LogFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/trooper/logger.rb

Constant Summary collapse

COLOURS =
{ 
  :black    => 30,
  :red      => 31, 
  :green    => 32, 
  :yellow   => 33,
  :blue     => 34,
  :magenta  => 35,
  :cyan     => 36,
  :white    => 37
}

Instance Method Summary collapse

Instance Method Details

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/trooper/logger.rb', line 49

def call(severity, datetime, progname, message)
  # DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN < ACTION < SUCCESS < STRATEGY
  case severity
  when "DEBUG"
    colour("#{progname} => [#{severity}] #{message}\n", :yellow)
  when "WARN"
    colour("#{progname} => [#{severity}] #{message}\n", :yellow)
  when "ACTION"
    colour("#{progname} => [#{severity}] #{message}\n", :magenta)
  when "SUCCESS"
    colour("#{progname} => [#{severity}] #{message}\n", :green)
  when "STRATEGY"
    colour("#{progname} => [#{severity}] #{message}\n", :cyan)
  when "ERROR", "FATAL"
    colour("#{progname} => [#{severity}] #{message}\n", :red)
  else
    "#{progname} => [#{severity}] #{message}\n"
  end
end