Class | Logger |
In: |
lib/lore/facets/logger.rb
|
Parent: | Object |
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?
SIMPLE_FORMAT | = | "%5s: %s\n" | Some available logging formats. | |
DETAILED_FORMAT | = | "%s %5s: %s\n" |
debug | -> | devel |
Why these names ? | ||
debug | -> | fine |
format_message | -> | format_message_without_proc |
format_proc | [RW] |
# 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
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.
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