Class: Franz::Logger

Inherits:
Logger show all
Defined in:
lib/franz/logger.rb

Overview

A powerful, colorful logger for Franz.

Constant Summary collapse

SEVERITY_COLORS =

Maps each log level to a unique combination of fore- and background colors

{
  'DEBUG' => [ :blue,    :default ],
  'INFO'  => [ :green,   :default ],
  'WARN'  => [ :yellow,  :default ],
  'ERROR' => [ :red,     :default ],
  'FATAL' => [ :red,     :black   ],
  'TRACE' => [ :magenta, :default ]
}

Constants inherited from Logger

Logger::TRACE

Instance Method Summary collapse

Methods inherited from Logger

#trace

Constructor Details

#initialize(debug = false, trace = false, out = nil) ⇒ Logger

Create a new, colorful logger.

Parameters:

  • debug (Boolean) (defaults to: false)

    enable DEBUG level logs

  • out (File) (defaults to: nil)

    output destination for logs



35
36
37
38
39
40
41
42
43
# File 'lib/franz/logger.rb', line 35

def initialize debug=false, trace=false, out=nil
  colorize = out.nil?
  out ||= $stdout
  super out
  format colorize
  @trace = true if trace
  self.level = ::Logger::INFO
  self.level = ::Logger::DEBUG if debug
end