Class: Hatchet::DelegatingFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/delegating_formatter.rb

Overview

Internal: Formatter class that delegates to another formatter implementation. Used within the configuration to make it possible to switch the default formatter at any time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formatter) ⇒ DelegatingFormatter

Internal: Creates a new instance.

formatter - The formatter to delegate to initially.



19
20
21
# File 'lib/hatchet/delegating_formatter.rb', line 19

def initialize(formatter)
  @formatter = formatter
end

Instance Attribute Details

#formatterObject

Internal: Gets or sets the formatter that is delegated to.



13
14
15
# File 'lib/hatchet/delegating_formatter.rb', line 13

def formatter
  @formatter
end

Instance Method Details

#format(level, context, message) ⇒ Object

Public: Returns the formatted message.

level - The severity of the log message. context - The context of the log message. message - The message provided by the log caller.

Returns messages as formatted by the formatter being delegated to.



31
32
33
# File 'lib/hatchet/delegating_formatter.rb', line 31

def format(level, context, message)
  @formatter.format(level, context, message)
end