Class: Ramaze::Logger::LogHub

Inherits:
Object
  • Object
show all
Includes:
Ramaze::Logging
Defined in:
lib/ramaze/log/hub.rb

Overview

Bundles different informer instances and sends incoming messages to each. This is the default with Informer as only member.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ramaze::Logging

#debug, #debug?, #dev, #error, #info, #shutdown, #tag_log, #warn

Constructor Details

#initialize(*loggers) ⇒ LogHub

Takes a list of instances or classes (which will be initialized) and that are added to @loggers. All messages are then sent to each member.



19
20
21
22
23
24
25
26
27
28
# File 'lib/ramaze/log/hub.rb', line 19

def initialize(*loggers)
  @loggers = loggers
  @ignored_tags = Set.new
  @loggers.map! do |logger|
    next(nil) if logger == self
    logger.is_a?(Class) ? logger.new : logger
  end
  @loggers.uniq!
  @loggers.compact!
end

Instance Attribute Details

#ignored_tagsObject

Returns the value of attribute ignored_tags.



14
15
16
# File 'lib/ramaze/log/hub.rb', line 14

def ignored_tags
  @ignored_tags
end

#loggersObject

Returns the value of attribute loggers.



13
14
15
# File 'lib/ramaze/log/hub.rb', line 13

def loggers
  @loggers
end

Instance Method Details

#log(tag, *args) ⇒ Object

integration to Logging



32
33
34
35
36
37
# File 'lib/ramaze/log/hub.rb', line 32

def log(tag, *args)
  return if @ignored_tags.include?(tag)
  @loggers.each do |logger|
    logger.log(tag, *args)
  end
end