Class: Gogetit::MultiLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/gogetit/multilogger.rb

Overview

It was just taken from below source. Thanks to clowder! gist.github.com/clowder/3639600

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ MultiLogger



9
10
11
12
13
14
# File 'lib/gogetit/multilogger.rb', line 9

def initialize(args={})
  @level = args[:level] || Logger::Severity::INFO
  @loggers = []

  Array(args[:loggers]).each { |logger| add_logger(logger) }
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



7
8
9
# File 'lib/gogetit/multilogger.rb', line 7

def level
  @level
end

Instance Method Details

#add(level, *args) ⇒ Object



42
43
44
# File 'lib/gogetit/multilogger.rb', line 42

def add(level, *args)
  @loggers.each { |logger| logger.add(level, args) }
end

#add_logger(logger) ⇒ Object



16
17
18
19
# File 'lib/gogetit/multilogger.rb', line 16

def add_logger(logger)
  logger.level = level
  @loggers << logger
end

#closeObject



38
39
40
# File 'lib/gogetit/multilogger.rb', line 38

def close
  @loggers.map(&:close)
end

#datetime_format=(format) ⇒ Object



26
27
28
# File 'lib/gogetit/multilogger.rb', line 26

def datetime_format=(format)
  @loggers.each { |logger| logger.datetime_format = format }
end

#formatter=(format) ⇒ Object



30
31
32
# File 'lib/gogetit/multilogger.rb', line 30

def formatter=(format)
  @loggers.each { |logger| logger.formatter = format }
end

#progname=(name) ⇒ Object



34
35
36
# File 'lib/gogetit/multilogger.rb', line 34

def progname=(name)
  @loggers.each { |logger| logger.progname = name }
end