class Pushapp::Logger

Attributes

shell[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/pushapp/logger.rb, line 8
def initialize
  super($stdout)
  @shell = Thor::Shell::Color.new

  self.progname = '[pushapp]'

          #  DEBUG  INFO    WARN     ERROR FATAL  UNKNOWN
  @colors = {
    'DEBUG'  => :blue,
    'INFO'   => :green,
    'WARN'   => :magenta,
    'ERROR'  => :red,
    'FATAL'  => :red,
    'UNKOWN' => :black
  }

  self.formatter = proc { |severity, datetime, progname, msg|
    color    = @colors[severity]

    progname = @shell.set_color progname, color, :bold
    sev      = @shell.set_color "#{severity}:", color
    msg      = @shell.set_color msg, color
    "#{progname} #{sev} #{msg}\n"
  }
end