A ANSI-colorized formatter for Logger instances. @private
Color settings
The Logger object associated with the formatter
The formats, by level
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
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