class LogKernel::Logger

Attributes

handlers[R]

Public Class Methods

[]( class_or_name ) click to toggle source
# File lib/logutils/logger.rb, line 120
def self.[]( class_or_name )
  STDLOGGER
end
new() click to toggle source
# File lib/logutils/logger.rb, line 128
def initialize
  @handlers = []
  @handlers << STDHANDLER   # by default log to console

  ## todo/check: pass levelno through to handlers?
  #   do we need a "global" levelno in the logger?
  @levelno = ALL
end
root() click to toggle source
# File lib/logutils/logger.rb, line 124
def self.root
  STDLOGGER
end

Public Instance Methods

debug( msg ) click to toggle source
# File lib/logutils/logger.rb, line 150
def debug( msg )
  write( Event.new( DEBUG, msg ) )
end
error( msg ) click to toggle source
# File lib/logutils/logger.rb, line 162
def error( msg )
  write( Event.new( ERROR, msg ) )
end
fatal( msg ) click to toggle source
# File lib/logutils/logger.rb, line 166
def fatal( msg )
  write( Event.new( FATAL, msg ) )
end
info( msg ) click to toggle source
# File lib/logutils/logger.rb, line 154
def info( msg )
  write( Event.new( INFO, msg ) )
end
level=( key ) click to toggle source

NB: use :debug, :info, :warn, :error, etc as argument

if invalid argument gets passed in, level gets set to UNKNOWN
# File lib/logutils/logger.rb, line 145
def level=( key )
  @levelno = LEVEL_HASH.fetch( key, UNKNOWN )
end
unknown( msg ) click to toggle source
# File lib/logutils/logger.rb, line 170
def unknown( msg )
  write( Event.new( UNKNOWN, msg ) )
end
warn( msg ) click to toggle source
# File lib/logutils/logger.rb, line 158
def warn( msg )
  write( Event.new( WARN, msg ) )
end

Private Instance Methods

write( ev ) click to toggle source
# File lib/logutils/logger.rb, line 176
def write( ev )
  if ev.levelno >= @levelno
    @handlers.each { |l| l.write( ev ) }
  end
end