Class: Kanal::Core::Logging::CompositeLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/kanal/core/logging/composite_logger.rb

Overview

Object of this class us used to store and use several loggers. It inherits from standard Logger and overrides it’s methods for accepting messages for every possible log level. Calling #debug (or any other loglevel) on this object results in calling #debug for every logger that it stores.

Instance Method Summary collapse

Constructor Details

#initializeCompositeLogger

Property allowed_methods defines which methods can be called. These methods mirror standard Logger methods.



16
17
18
# File 'lib/kanal/core/logging/composite_logger.rb', line 16

def initialize
  @loggers = []
end

Instance Method Details

#add_logger(logger) ⇒ Object



20
21
22
# File 'lib/kanal/core/logging/composite_logger.rb', line 20

def add_logger(logger)
  @loggers << logger
end

#debug(message) ⇒ Object



24
25
26
# File 'lib/kanal/core/logging/composite_logger.rb', line 24

def debug(message)
  feed_message_to_loggers :debug, caller_class_name(caller.first), message
end

#error(message) ⇒ Object



36
37
38
# File 'lib/kanal/core/logging/composite_logger.rb', line 36

def error(message)
  feed_message_to_loggers :error, caller_class_name(caller.first), message
end

#fatal(message) ⇒ Object



40
41
42
# File 'lib/kanal/core/logging/composite_logger.rb', line 40

def fatal(message)
  feed_message_to_loggers :fatal, caller_class_name(caller.first), message
end

#info(message) ⇒ Object



28
29
30
# File 'lib/kanal/core/logging/composite_logger.rb', line 28

def info(message)
  feed_message_to_loggers :info, caller_class_name(caller.first), message
end

#unknown(message) ⇒ Object



44
45
46
# File 'lib/kanal/core/logging/composite_logger.rb', line 44

def unknown(message)
  feed_message_to_loggers :unknown, caller_class_name(caller.first), message
end

#warn(message) ⇒ Object



32
33
34
# File 'lib/kanal/core/logging/composite_logger.rb', line 32

def warn(message)
  feed_message_to_loggers :warn, caller_class_name(caller.first), message
end