Class: Airbrussh::LogFileFormatter

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

Overview

A Pretty formatter that sends its output to a specified log file path. LogFileFormatter takes care of creating the file (and its parent directory) if it does not already exist, opens it for appending, and writes a delimiter message. The file is automatically rotated if it reaches 20 MB.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, formatter_class = SSHKit::Formatter::Pretty) ⇒ LogFileFormatter

Returns a new instance of LogFileFormatter.



15
16
17
18
19
20
# File 'lib/airbrussh/log_file_formatter.rb', line 15

def initialize(path, formatter_class=SSHKit::Formatter::Pretty)
  @path = path
  ensure_directory_exists if path.is_a?(String)
  super(formatter_class.new(log_file_io))
  write_delimiter
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/airbrussh/log_file_formatter.rb', line 13

def path
  @path
end