Sha256: 6124b5436d8770c91bc6e357c97003a5ce8b27309adc6208ecd64e6423b7e4cf
Contents?: true
Size: 651 Bytes
Versions: 127
Compression:
Stored size: 651 Bytes
Contents
# try out a custom formatter $: << '../lib' require "log4r" class MyFormatter < Log4r::Formatter def format(event) buff = "The level is #{event.level} and has " buff += "name '#{Log4r::LNAMES[event.level]}'\n" buff += "The logger is '#{event.name}' " buff += "and the data type is #{event.data.class}\n" buff += "Let's inspect the data:\n" buff += event.data.inspect + "\n" buff += "We were called at #{event.tracer[0]}\n\n" end end log = Log4r::Logger.new('custom formatter') log.trace = true log.add Log4r::StdoutOutputter.new('stdout', :formatter=>MyFormatter) log.info [1, 2, 3, 4] log.error "A log statement"
Version data entries
127 entries across 89 versions & 15 rubygems