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
ansicolor=
format_procedure
setup_format
Included Modules
Classes and Modules
Module Logger::AnsicolorClass Logger::LogDevice
Constants
SIMPLE_FORMAT | = | "%5s: %s\n" |
Some available logging formats. | ||
DETAILED_FORMAT | = | "%s %5s: %s\n" |
Attributes
[RW] | format_proc |
Public Instance methods
[ + ]
# 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
[ + ]
# 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
[ + ]
# 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