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

Version Path
depengine-0.0.18 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.17 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.16 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.15 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.14 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.13 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.13 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/log4r-1.1.10/examples/myformatter.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-shell-0.2.6 vendor/bundle/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-shell-0.2.5 vendor/bundle/gems/log4r-1.1.10/examples/myformatter.rb
depengine-0.0.12 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.12 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.11 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.11 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb