Class: Maze::Loggers::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/maze/loggers/logger.rb

Direct Known Subclasses

FileLogger, STDOUTLogger

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

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_loggerObject

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_loggerObject

Returns the value of attribute stdout_logger.



41
42
43
# File 'lib/maze/loggers/logger.rb', line 41

def stdout_logger
  @stdout_logger
end