Class: BBK::Utils::CombinedLogger

Inherits:
Object
  • Object
show all
Includes:
Logger::Severity
Defined in:
lib/bbk/utils/combined_logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(progname, *loggers, formatter: LogFormatter.new, level: Logger::Severity::INFO) ⇒ CombinedLogger

Returns a new instance of CombinedLogger.



17
18
19
20
21
22
# File 'lib/bbk/utils/combined_logger.rb', line 17

def initialize(progname, *loggers, formatter: LogFormatter.new, level: Logger::Severity::INFO)
  @loggers = loggers
  self.progname = progname
  self.level = level
  self.formatter = formatter
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object



63
64
65
66
# File 'lib/bbk/utils/combined_logger.rb', line 63

def method_missing(name, *args, **kwargs, &block)
  @loggers.each {|logger| logger.send(name, *args, **kwargs, &block)}
  nil
end

Instance Attribute Details

#formatterObject

Returns the value of attribute formatter.



11
12
13
# File 'lib/bbk/utils/combined_logger.rb', line 11

def formatter
  @formatter
end

#levelObject Also known as: sev_threshold

Returns the value of attribute level.



11
12
13
# File 'lib/bbk/utils/combined_logger.rb', line 11

def level
  @level
end

#loggersObject (readonly)

Returns the value of attribute loggers.



11
12
13
# File 'lib/bbk/utils/combined_logger.rb', line 11

def loggers
  @loggers
end

#prognameObject

Returns the value of attribute progname.



11
12
13
# File 'lib/bbk/utils/combined_logger.rb', line 11

def progname
  @progname
end

Class Method Details

.new(*args, **kwargs) ⇒ Object



13
14
15
# File 'lib/bbk/utils/combined_logger.rb', line 13

def self.new(*args, **kwargs)
  ActiveSupport::TaggedLogging.new(super)
end

Instance Method Details

#cloneObject



68
69
70
71
72
# File 'lib/bbk/utils/combined_logger.rb', line 68

def clone
  super.tap do |it| 
    it.instance_variable_set(:@loggers, loggers.map(&:clone)) 
  end 
end