class Baha::Log

Constants

LEVELS

Attributes

io[R]
level[R]
logfile[R]
progname[R]

Public Class Methods

close!() click to toggle source
# File lib/baha/log.rb, line 53
def close!
  if @logfile
    @logfile.close
    @logfile = nil
  end
end
for_name(progname) click to toggle source
# File lib/baha/log.rb, line 59
def for_name(progname)
  Baha::Log.new(progname)
end
level=(level) click to toggle source
# File lib/baha/log.rb, line 40
def level=(level)
  key = case level
  when String
    @level = level.downcase.to_sym
  when Symbol
    @level = level.downcase
  else
    raise ArgumentError.new("level must be a string or symbol")
  end
  raise ArgumentError.new("level must be in #{LEVELS.keys}") unless LEVELS.has_key?(key)
  @level = key
  self.logfile.sev_threshold = LEVELS[@level]
end
logfile=(io) click to toggle source
# File lib/baha/log.rb, line 34
def logfile=(io)
  @io = io
  @logfile = Logger.new(io)
  @logfile.formatter = Baha::Log::Formatter.new()
  self.level = :error
end
new(progname) click to toggle source
# File lib/baha/log.rb, line 66
def initialize(progname)
  @progname = progname
end