Class: Maze::Loggers::Logger
- Inherits:
-
Object
- Object
- Maze::Loggers::Logger
- Includes:
- Singleton
- Defined in:
- lib/maze/loggers/logger.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_logger ⇒ Object
Returns the value of attribute file_logger.
-
#stdout_logger ⇒ Object
Returns the value of attribute stdout_logger.
Instance Method Summary collapse
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#method_missing(method, *args, &block) ⇒ Object
Attempts to forward all method calls to both loggers.
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
43 44 45 46 |
# File 'lib/maze/loggers/logger.rb', line 43 def initialize @stdout_logger = Maze::Loggers::STDOUTLogger.instance @file_logger = Maze::Loggers::FileLogger.instance end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Attempts to forward all method calls to both loggers
49 50 51 52 53 54 55 56 |
# File 'lib/maze/loggers/logger.rb', line 49 def method_missing(method, *args, &block) if @stdout_logger.respond_to?(method) && @file_logger.respond_to?(method) @stdout_logger.send(method, *args, &block) @file_logger.send(method, *args, &block) else super end end |
Instance Attribute Details
#file_logger ⇒ Object
Returns the value of attribute file_logger.
41 42 43 |
# File 'lib/maze/loggers/logger.rb', line 41 def file_logger @file_logger end |
#stdout_logger ⇒ Object
Returns the value of attribute stdout_logger.
41 42 43 |
# File 'lib/maze/loggers/logger.rb', line 41 def stdout_logger @stdout_logger end |