class Scoutui::Logger::LogMgr

Constants

LOGLEVELS

Attributes

benchmarks[RW]
commands[RW]
level[RW]
root[RW]

Public Class Methods

new() click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 16
def initialize

  @root = Logging.logger(STDOUT)
  @root.level = :debug
  @level = LOGLEVELS[DEBUG]

  Logging.appenders.stderr('Standard Error', :level => :error)

  # Logging.appenders.file('Command File', :filename => 'command.log')
  # Logging.logger['Commands'].appenders = 'Command File'

  @asserts = Logging.logger['Assertions']
  @asserts.add_appenders(
              Logging.appenders.stdout
  )
  @asserts.add_appenders(
              Logging.appenders.file("assertions.log")
  )

  @asserts.level = :debug

  @commands = Logging.logger['Commands']
  @commands.add_appenders(
               Logging.appenders.stdout,
               Logging.appenders.file('commands.log')
  )
  @commands.level = :debug


  @benchmarks = Logging.logger['Benchmarks']
  @benchmarks.add_appenders(
      Logging.appenders.stdout,
      Logging.appenders.file('benchmarks.log')
  )
  @benchmarks.level = :info

  #Logging.logger.root.level = :warn
end

Public Instance Methods

asserts() click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 55
def asserts
  @asserts
end
benchmark() click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 112
def benchmark
  @benchmarks
end
command() click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 59
def command
  @commands
end
debug(txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 107
def debug(txt)
  log('debug', txt)
end
err(txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 91
def err(txt)
  error(txt)
end
error(txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 95
def error(txt)
  log('error', txt)
end
fatal(txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 99
def fatal(txt)
  log('fatal', txt)
end
info(txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 103
def info(txt)
  log('info', txt)
end
log(level, txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 120
def log(level, txt)

  if level.match(/debug/i)
    @root.debug txt if DEBUG >= @level
  elsif level.match(/info/i)
    @root.info txt  if INFO >= @level
  elsif level.match(/warn/i)
    @root.warn txt  if WARN >= @level
  elsif level.match(/error/i)
    @root.error txt if ERROR >= @level
  elsif level.match(/fatal/i)
    @root.fatal txt  if FATAL >= @level
  end

end
setLevel(_level) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 66
def setLevel(_level)

  @asserts.level = @benchmarks.level = @commands.level = @root.level = _level.to_sym

  _l = _level.to_s
  if _l.match(/debug/i)
    @level = LOGLEVELS[DEBUG]
  elsif _l.match(/info/i)
    @level = LOGLEVELS[INFO]
  elsif _l.match(/warn/i)
    @level = LOGLEVELS[WARN]
  elsif _l.match(/error/i)
    @level = LOGLEVELS[ERROR]
  elsif _l.match(/fatal/i)
    @level = LOGLEVELS[FATAL]
  else
    raise "UNKNOWN_LEVEL"
  end

end
warn(txt) click to toggle source
# File lib/scoutui/logger/log_mgr.rb, line 87
def warn(txt)
  log('warn', txt)
end