Class: Airbrussh::DelegatingFormatter

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

Overview

This class quacks like an SSHKit::Formatter, but when any formatting methods are called, it simply forwards them to one more more concrete formatters. This allows us to split out the responsibilities of ConsoleFormatter and LogFileFormatter into two separate classes, with DelegatingFormatter forwarding the logging messages to both at once.

Direct Known Subclasses

Formatter

Constant Summary collapse

FORWARD_METHODS =
%w[
  fatal error warn info debug log
  log_command_start log_command_data log_command_exit
].freeze
DUP_AND_FORWARD_METHODS =
%w[<< write].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formatters) ⇒ DelegatingFormatter

Returns a new instance of DelegatingFormatter.



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

def initialize(formatters)
  @formatters = formatters
end

Instance Attribute Details

#formattersObject (readonly)

Returns the value of attribute formatters.



17
18
19
# File 'lib/airbrussh/delegating_formatter.rb', line 17

def formatters
  @formatters
end