Treequel::

ColorLogFormatter

class
Superclass
Logger::Formatter
Extended With
Treequel::ANSIColorUtilities

A ANSI-colorized formatter for Logger instances. @private

Constants

LEVEL_FORMATS

Color settings

Attributes

logger[RW]

The Logger object associated with the formatter

settings[RW]

The formats, by level

Public Instance Methods

anchor
call( severity, time, progname, msg )

Log using the format associated with the severity

# File lib/treequel/utils.rb, line 107
def call( severity, time, progname, msg )
        args = [
                time.strftime( '%Y-%m-%d %H:%M:%S' ),                         # %1$s
                time.usec,                                                    # %2$d
                Process.pid,                                                  # %3$d
                Thread.current == Thread.main ? 'main' : Thread.object_id,    # %4$s
                severity,                                                     # %5$s
                progname,                                                     # %6$s
                msg                                                           # %7$s
        ]

        return self.settings[ severity.downcase.to_sym ] % args
end

Protected Instance Methods

anchor
initialize( logger, settings={} )

Initialize the formatter with a reference to the logger so it can check for log level.

# File lib/treequel/utils.rb, line 86
def initialize( logger, settings={} ) # :notnew:
        settings = LEVEL_FORMATS.merge( settings )

        @logger   = logger
        @settings = settings

        super()
end