Class: BuildpackSupport::Logging::DelegatingLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/buildpack_support/logging/delegating_logger.rb

Overview

A Logger subclass that forwards all messages to a collection of delegates

Instance Method Summary collapse

Constructor Details

#initialize(klass, delegates) ⇒ DelegatingLogger

Creates an instance

Parameters:

  • klass (Class)

    the class to use as the progname for log messages

  • delegates (Array<Logger>)

    the Logger instances to delegate to



29
30
31
32
# File 'lib/buildpack_support/logging/delegating_logger.rb', line 29

def initialize(klass, delegates)
  @klass     = klass
  @delegates = delegates
end

Instance Method Details

#add(severity, message = nil, progname = nil) { ... } ⇒ Void

Adds a message to the delegate Logger instances

Parameters:

  • severity (Logger::Severity)

    the severity of the message

  • message (String) (defaults to: nil)

    the message

  • progname (String) (defaults to: nil)

    the message when passed in as a parameter

Yields:

  • evaluated for the message

Returns:

  • (Void)


41
42
43
# File 'lib/buildpack_support/logging/delegating_logger.rb', line 41

def add(severity, message = nil, progname = nil, &block)
  @delegates.each { |delegate| delegate.add severity, message || progname, @klass, &block }
end