Class ANSI::Logger
In: lib/ansi/logger.rb
Parent: Logger

ANSI::Logger

Extended variation of Ruby‘s standard Logger library that supports color output.

  log = ANSI::Logger.new

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

Methods

ansicolor=   ansicolor?   debug   error   fatal   formatter   info   styles   warn  

Constants

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

Public Instance methods

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, progname and msg.

Example

  logger = ANSI::Logger.new

  logger.formatter do |severity, timestamp, progname, msg|
    "#{progname}@#{timestamp} - #{severity}::#{msg}"
  end

[Validate]