Class: Pantry::Logger
- Inherits:
-
Object
- Object
- Pantry::Logger
- 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
-
#disable! ⇒ Object
Turn off all logging entirely.
-
#initialize(config = Pantry.config) ⇒ Logger
constructor
A new instance of Logger.
-
#method_missing(*args) ⇒ Object
Forward all methods on to the internal Celluloid Logger.
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
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 |