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
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/log4r-1.1.10/examples/myformatter.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/log4r-1.1.10/examples/myformatter.rb
depengine-0.0.31 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.31 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/myformatter.rb