Class: Dumbcli::Logger

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

Constant Summary collapse

CLEAR =
"\e[0m"
COLORS =
{
  'INFO'  => "\e[32m",  # green
  'WARN'  => "\e[33m",  # yellow
  'ERROR' => "\e[35m",  # magenta
  'FATAL' => "\e[31m",  # red
}

Instance Method Summary collapse

Constructor Details

#initialize(logdev, shift_age = 0, shift_size = 1048576) ⇒ Logger

Returns a new instance of Logger.



13
14
15
16
# File 'lib/dumbcli/logger.rb', line 13

def initialize(logdev, shift_age = 0, shift_size = 1048576)
  super
  @level = INFO
end

Instance Method Details

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



18
19
20
21
22
23
24
# File 'lib/dumbcli/logger.rb', line 18

def format_message(severity, datetime, progname, msg)
  if COLORS[severity]
    "#{COLORS[severity]}#{super}#{CLEAR}"
  else
    super
  end
end