Class: Ramaze::LogHub

Inherits:
Object show all
Includes:
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 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.



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

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.



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

def ignored_tags
  @ignored_tags
end

#loggersObject

Returns the value of attribute loggers.



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

def loggers
  @loggers
end

Instance Method Details

#log(tag, *args) ⇒ Object

integration to Logging



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

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