Class: ConsoleFormatter

Inherits:
Log4r::BasicFormatter
  • Object
show all
Defined in:
lib/maestro/log4r/console_formatter.rb

Overview

Custom Log4r formatter for the console

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ ConsoleFormatter

Returns a new instance of ConsoleFormatter.



6
7
8
# File 'lib/maestro/log4r/console_formatter.rb', line 6

def initialize(hash={})
  super(hash)
end

Instance Method Details

#format(logevent) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/maestro/log4r/console_formatter.rb', line 10

def format(logevent)
  if Log4r::LNAMES[logevent.level].eql? "PROGRESS"
    # Formats the data as is with no newline, to allow progress bars to be logged.
    sprintf("%s", logevent.data.to_s)
  else
    format_object(logevent.data) + "\n"
  end
end