class Sawmill::RecordProcessor::Format

This processor formats log records and writes them to a destination.

Public Class Methods

new(destination_, opts_={}) click to toggle source

Create a formatter.

The destination can be a ruby IO object, a Sawmill::Rotater, or any object that responds to the “write” and “close” methods as defined by the ruby IO class.

Recognized options include:

:include_id

Include the record ID in every log entry. Default is false.

:fractional_second_digits

Number of digits of fractional seconds to display in timestamps. Default is 2. Accepted values are 0 to 6.

:level_width

Column width of the level field.

:entry_length_limit

Limit to the entry length. Entries are truncated to this length when written. If not specified, entries are not truncated.

# File lib/sawmill/record_processor/format.rb, line 66
def initialize(destination_, opts_={})
  if (entry_length_limit_ = opts_.delete(:entry_length_limit))
    opts_ = opts_.merge(:length_limit => entry_length_limit_)
  end
  @formatter = EntryProcessor::Format.new(destination_, opts_)
  @classifier = EntryClassifier.new(@formatter)
end

Public Instance Methods

extra_entry(entry_) click to toggle source
# File lib/sawmill/record_processor/format.rb, line 80
def extra_entry(entry_)
  @classifier.entry(entry_)
  true
end
finish() click to toggle source
# File lib/sawmill/record_processor/format.rb, line 85
def finish
  @formatter.finish
end
record(record_) click to toggle source
# File lib/sawmill/record_processor/format.rb, line 75
def record(record_)
  record_.each_entry{ |entry_| @classifier.entry(entry_) }
  true
end