Module: Raad::Logger

Extended by:
Logger
Included in:
Logger
Defined in:
lib/raad/logger.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object (private)



59
60
61
# File 'lib/raad/logger.rb', line 59

def method_missing(sym, *args)
  @log.send(sym, *args)
end

Instance Method Details

#level=(l) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/raad/logger.rb', line 23

def level=(l)
  levels = {
    :debug => Log4r::DEBUG,
    :info => Log4r::INFO,
    :warn => Log4r::WARN,
    :error => Log4r::ERROR,
  }
  @log.level = @verbose ? Log4r::DEBUG : levels[l]
end

#setup(options = {}) ⇒ Logger

Sets up the logging for the runner

Returns:

  • (Logger)

    The logger object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/raad/logger.rb', line 10

def setup(options = {})
  @log = Log4r::Logger.new('raad')

  log_format = Log4r::PatternFormatter.new(:pattern => "[#{Process.pid}:%l] %d :: %m")
  setup_file_logger(@log, log_format, options[:file]) if options[:file]
  setup_stdout_logger(@log, log_format) if options[:stdout]

  @verbose = !!options[:verbose]

  @log.level = @verbose ? Log4r::DEBUG : Log4r::INFO
  @log
end