Module: TinkitLog

Includes:
Log4r
Defined in:
lib/helpers/log_helper.rb

Overview

Set Logger TODO: Create spec

Constant Summary collapse

@@log_levels =
{ :debug => DEBUG,
  :info => INFO,
  :warn => WARN,
  :error => ERROR,
  :fatal => FATAL
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_levelObject

Returns the value of attribute default_level.



8
9
10
# File 'lib/helpers/log_helper.rb', line 8

def default_level
  @default_level
end

.fatal_logObject

Returns the value of attribute fatal_log.



8
9
10
# File 'lib/helpers/log_helper.rb', line 8

def fatal_log
  @fatal_log
end

.log_outputObject

Returns the value of attribute log_output.



8
9
10
# File 'lib/helpers/log_helper.rb', line 8

def log_output
  @log_output
end

Class Method Details

.log_raise(error_msg, exc_type = RuntimeError) ⇒ Object

Raises:

  • (exc_type)


30
31
32
33
# File 'lib/helpers/log_helper.rb', line 30

def self.log_raise(error_msg, exc_type= RuntimeError)
  self.fatal_log.fatal("#{__LINE__} #{error_msg}") 
  raise exc_type, error_msg
end

.set(name, level = TinkitLog.default_level, out = Outputter.stdout) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/helpers/log_helper.rb', line 22

def self.set(name, level=TinkitLog.default_level, out=Outputter.stdout)
  log = Logger[name] || Logger.new(name)
  log.outputters = out
  log.level = @@log_levels[level]
  log.trace = true if log.level <= DEBUG
  log
end