class Pantry::Logger
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)
Public Class Methods
new(config = Pantry.config)
click to toggle source
# 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
Public Instance Methods
disable!()
click to toggle source
Turn off all logging entirely
# File lib/pantry/logger.rb, line 32 def disable! Celluloid.logger = NullLogger.new end
Protected Instance Methods
log_level(log_level_string)
click to toggle source
# File lib/pantry/logger.rb, line 43 def log_level(log_level_string) case log_level_string.to_s when "debug" ::Logger::DEBUG when "info" ::Logger::INFO when "warn" ::Logger::WARN when "error" ::Logger::ERROR when "fatal" ::Logger::FATAL else raise "Unknown log level given: #{log_level_string}" end end