Class: Sq::Dbsync::Loggers::Composite

Inherits:
Abstract
  • Object
show all
Defined in:
lib/sq/dbsync/loggers.rb

Overview

Combines multiple loggers together.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loggers = nil) ⇒ Composite

Returns a new instance of Composite.



70
71
72
# File 'lib/sq/dbsync/loggers.rb', line 70

def initialize(loggers = nil)
  @loggers = loggers
end

Instance Attribute Details

#loggersObject

Returns the value of attribute loggers.



68
69
70
# File 'lib/sq/dbsync/loggers.rb', line 68

def loggers
  @loggers
end

Instance Method Details

#log(str) ⇒ Object



85
86
87
# File 'lib/sq/dbsync/loggers.rb', line 85

def log(str)
  loggers.each { |logger| logger.log(str) }
end

#measure(label, &block) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/sq/dbsync/loggers.rb', line 74

def measure(label, &block)
  # Babushka doll! Logger inside a logger inside a logger.
  loggers.inject(block) do |block, logger|
    lambda do
      logger.measure(label) do
        block.call
      end
    end
  end.call
end