Class: BammLog::Logger::EnvLogger
- Inherits:
-
Object
- Object
- BammLog::Logger::EnvLogger
- Defined in:
- lib/bamm_log.rb
Overview
————————————————————- loggers
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app) ⇒ EnvLogger
constructor
A new instance of EnvLogger.
- #method_missing(method, args, &block) ⇒ Object
Constructor Details
#initialize(app) ⇒ EnvLogger
Returns a new instance of EnvLogger.
37 38 39 40 41 42 |
# File 'lib/bamm_log.rb', line 37 def initialize(app) self.logger = ::Logger.new(EnvLogger.log_file(app)).tap do |logger| ::Logger.class_eval { alias :write :'<<' } logger.level = ::Logger::INFO end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, args, &block) ⇒ Object
50 51 52 |
# File 'lib/bamm_log.rb', line 50 def method_missing(method, args, &block) logger.send(method, args, &block) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
35 36 37 |
# File 'lib/bamm_log.rb', line 35 def logger @logger end |
Class Method Details
.log_file(app) ⇒ Object
44 45 46 47 48 |
# File 'lib/bamm_log.rb', line 44 def self.log_file(app) @log_file ||= File.new("#{app.root}/log/#{app.environment}.log", 'a+').tap do |log_file| log_file.sync = true end end |