Class: Halcyon::Logging::Log4r

Inherits:
Log4r::Logger
  • Object
show all
Defined in:
lib/halcyon/logging/log4r.rb

Class Method Summary collapse

Class Method Details

.setup(config) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/halcyon/logging/log4r.rb', line 9

def setup(config)
  logger = self.new(config[:label] || Halcyon.app)
  if config[:file]
    logger.outputters = Log4r::FileOutputter.new(:filename => config[:file])
  else
    logger.outputters = Log4r::Outputter.stdout
  end
  logger.level = Object.const_get((config[:level] || 'debug').upcase.to_sym)
  logger.outputters[0].formatter = Log4r::PatternFormatter.new(:pattern => "%5l [%d] (#{$$}) #{Halcyon.app} :: %m\n", :date_pattern => "%Y-%m-%d %H:%M:%S")
  logger
end