Class: Pantry::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/pantry/logger.rb

Overview

Wrapper around the Celluloid’s logging system. Depending on the passed in config, will send to STDOUT, Syslog, or a given file. See Celluloid::Logger for API (should be the same as Ruby’s Logger API)

Instance Method Summary collapse

Constructor Details

#initialize(config = Pantry.config) ⇒ Logger

Returns a new instance of Logger.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pantry/logger.rb', line 17

def initialize(config = Pantry.config)
  logger =
    if config.log_to.nil? || config.log_to == "stdout"
      ::Logger.new(STDOUT)
    elsif config.log_to == "syslog"
      ::Syslog::Logger.new(config.syslog_program_name)
    else
      ::Logger.new(config.log_to)
    end

  logger.level = log_level(config.log_level)
  Celluloid.logger = logger
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object

Forward all methods on to the internal Celluloid Logger.



37
38
39
# File 'lib/pantry/logger.rb', line 37

def method_missing(*args)
  Celluloid.logger.send(*args) if Celluloid.logger
end

Instance Method Details

#disable!Object

Turn off all logging entirely



32
33
34
# File 'lib/pantry/logger.rb', line 32

def disable!
  Celluloid.logger = NullLogger.new
end