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.

Parameters:

  • meth (Symbol) —

    the method to invoke

  • args (Array) —

    arguments to forward to each sink

Yields:

  • an optional block forwarded to each sink

Returns:

  • (Object) —

    the last sink's return value



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.

Parameters:

  • meth (Symbol) —

    the method to invoke

  • args (Array) —

    arguments to forward to the sink

Yields:

  • an optional block forwarded to the sink

Returns:

  • (Object) —

    the first sink's return value



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

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