Class Logger
In: lib/lore/facets/logger.rb
Parent: Object

Logger

Extended variation of Ruby‘s standard Logger library. Mainly for compatibility purposes (with what?)

  log = Logger.new

  log.setup_format do |severity, timestamp, progname, msg|
    Logger::SIMPLE_FORMAT % [severity, msg]
  end

When using debug level logger messages always append ‘if $DBG’ at the end. This hack is needed because Ruby does not support lazy evaluation (lisp macros).

TODO: What‘s all this about then?

Methods

Included Modules

Ansicolor

Classes and Modules

Module Logger::Ansicolor
Class Logger::LogDevice

Constants

SIMPLE_FORMAT = "%5s: %s\n"   Some available logging formats.
DETAILED_FORMAT = "%s %5s: %s\n"

External Aliases

debug -> devel
  Why these names ?
debug -> fine
format_message -> format_message_without_proc

Attributes

format_proc  [RW] 

Public Instance methods

[Source]

# File lib/lore/facets/logger.rb, line 66
  def ansicolor=(on)
    unless is_a?(Ansicolor)
      class << self
        include Ansicolor
      end
    end
    @logdev.ansicolor = on
  end

[Source]

# File lib/lore/facets/logger.rb, line 156
  def format_procedure
    @format_proc
  end

Dictate the way in which this logger should format the messages it displays. This method requires a block. The block should return formatted strings given severity, timestamp, msg, progname.

Example

logger = Logger.new logger.setup_format do |severity, timestamp, msg, progname|

  "#{progname}@#{timestamp} - #{severity}::#{msg}"

end

[Source]

# File lib/lore/facets/logger.rb, line 151
  def setup_format(&format_proc)
    raise "Formating block needed" unless format_proc
    @format_proc = format_proc
  end

[Validate]