Module: Logging

Includes:
Log4r
Included in:
Trellis::Application
Defined in:
lib/trellis/logging.rb

Overview

:nodoc: all

Class Method Summary collapse

Class Method Details

.included(recipient) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/trellis/logging.rb', line 49

def Logging.included(recipient)
  cfg = YamlConfigurator
  cfg['HOME'] = '.'
  begin
    cfg.load_yaml_file('logging.yaml') #TODO make this configurable
    logger = Logger['trellis']
  rescue
    logger = Logger.new 'trellis'
    formatter = PatternFormatter.new(:pattern => '%d %l: %m ', :date_pattern => '%y%m%d %H:%M:%S')
    logger.add Log4r::StdoutOutputter.new('stdout', :formatter=> formatter)
  end  
  logger.level = INFO
  recipient.instance_variable_set(:@logger, logger)  
  recipient.class.send(:define_method, :logger) { @logger }
end

.loggerObject



45
46
47
# File 'lib/trellis/logging.rb', line 45

def self.logger
  @@logger
end