Class: Kitchen::Logger::SinkSet

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/logger.rb

Overview

Internal composite for forwarding stdlib Logger-compatible calls to all configured logging sinks.

Instance Method Summary collapse

Constructor Details

#initialize(loggers) ⇒ SinkSet

Returns a new instance of SinkSet.



365
366
367
# File 'lib/kitchen/logger.rb', line 365

def initialize(loggers)
  @loggers = loggers
end

Instance Method Details

#all(meth, *args) { ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Invokes a method on every configured sink. A given block is memoized so that an expensive message block is evaluated at most once, no matter how many sinks consume it.

Yields:

  • an optional block forwarded to each sink

Parameters:

  • the method to invoke

  • arguments to forward to each sink

Returns:

  • the last sink's return value

API:

  • private



389
390
391
392
393
394
# File 'lib/kitchen/logger.rb', line 389

def all(meth, *args, &block)
  result = nil
  block = memoized_block(block) if block
  @loggers.each { |logger| result = logger.public_send(meth, *args, &block) }
  result
end

#first(meth, *args) { ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Invokes a method on the first configured sink only.

Yields:

  • an optional block forwarded to the sink

Parameters:

  • the method to invoke

  • arguments to forward to the sink

Returns:

  • the first sink's return value

API:

  • private



376
377
378
# File 'lib/kitchen/logger.rb', line 376

def first(meth, *args, &block)
  @loggers.first.public_send(meth, *args, &block)
end