Class: Workerholic::LogManager

Inherits:
Object
  • Object
show all
Defined in:
lib/workerholic/log_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogManager

Returns a new instance of LogManager.



5
6
7
# File 'lib/workerholic/log_manager.rb', line 5

def initialize
  @logger = Logger.new(STDOUT)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/workerholic/log_manager.rb', line 3

def logger
  @logger
end

Instance Method Details

#error(message) ⇒ Object



13
14
15
# File 'lib/workerholic/log_manager.rb', line 13

def error(message)
  log('error', message)
end

#info(message) ⇒ Object



9
10
11
# File 'lib/workerholic/log_manager.rb', line 9

def info(message)
  log('info', message)
end

#log(severity, message) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/workerholic/log_manager.rb', line 17

def log(severity, message)
  return if $TESTING

  logger.formatter = proc do |severity, datetime, progname, msg|
    "#{severity}: #{msg}\n"
  end

  logger.send(severity, message)
end