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.

Since:

  • 11-08-2009

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.

Parameters:

  • loggers (Array)

Since:

  • 11-08-2009



22
23
24
25
26
27
28
29
30
31
# File 'lib/ramaze/log/hub.rb', line 22

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

Since:

  • 11-08-2009



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

def ignored_tags
  @ignored_tags
end

#loggersObject

Since:

  • 11-08-2009



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

Parameters:

  • tag (String)
  • args (Hash)

Since:

  • 11-08-2009



39
40
41
42
43
44
# File 'lib/ramaze/log/hub.rb', line 39

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