Class: Wildsight::Agent::Logger
- Inherits:
-
Object
- Object
- Wildsight::Agent::Logger
- Defined in:
- lib/wildsight/agent/logger.rb
Constant Summary collapse
- TABLE =
{ :debug => ::Logger::DEBUG, :info => ::Logger::INFO, :warn => ::Logger::WARN, :error => ::Logger::ERROR, :fatal => ::Logger::FATAL, 'debug' => ::Logger::DEBUG, 'info' => ::Logger::INFO, 'warn' => ::Logger::WARN, 'error' => ::Logger::ERROR, 'fatal' => ::Logger::FATAL }
Instance Method Summary collapse
-
#initialize(config) ⇒ Logger
constructor
A new instance of Logger.
- #log(severity, message = nil, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ Logger
Returns a new instance of Logger.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wildsight/agent/logger.rb', line 21 def initialize(config) @config = config @loggers = [] if @config['logger']['stdout'] @loggers << ::Logger.new(STDOUT) end if @config['logger']['stderr'] @loggers << ::Logger.new(STDERR) end if @config['logger']['file'] && @config['logger']['file'].kind_of?(String) @loggers << ::Logger.new(@config['logger']['file']) end @loggers.each { |logger| logger.level = TABLE[@config['logger']['level']] } end |
Instance Method Details
#log(severity, message = nil, &block) ⇒ Object
40 41 42 |
# File 'lib/wildsight/agent/logger.rb', line 40 def log(severity, = nil, &block) @loggers.each { |logger| logger.add(TABLE[severity] || ::Logger::UNKNOWN, nil, , &block) } end |