Parent

Files

Class/Module Index [+]

Quicksearch

God::SimpleLogger

Attributes

datetime_format[RW]
level[RW]

Public Class Methods

new(io) click to toggle source
# File lib/god/simple_logger.rb, line 24
def initialize(io)
  @io = io
  @level = INFO
  @datetime_format = "%Y-%m-%d %H:%M:%S"
end

Public Instance Methods

debug(msg) click to toggle source
# File lib/god/simple_logger.rb, line 54
def debug(msg)
  self.output(DEBUG, msg)
end
error(msg) click to toggle source
# File lib/god/simple_logger.rb, line 42
def error(msg)
  self.output(ERROR, msg)
end
fatal(msg) click to toggle source
# File lib/god/simple_logger.rb, line 38
def fatal(msg)
  self.output(FATAL, msg)
end
info(msg) click to toggle source
# File lib/god/simple_logger.rb, line 50
def info(msg)
  self.output(INFO, msg)
end
output(level, msg) click to toggle source
# File lib/god/simple_logger.rb, line 30
def output(level, msg)
  return if level < self.level

  time = Time.now.strftime(self.datetime_format)
  label = SEV_LABEL[level]
  @io.print("#{label[0..0]} [#{time}] #{label.rjust(5)}: #{msg}\n")
end
warn(msg) click to toggle source
# File lib/god/simple_logger.rb, line 46
def warn(msg)
  self.output(WARN, msg)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.