class Lumberjack::Device::Writer

def initialize(stream, options = {})

Parameters:
  • options (Hash) -- The options for the device.
  • stream (IO) -- The stream to write log entries to.
def initialize(stream, options = {})
  @lock = Mutex.new
  @stream = stream
  @stream.sync = true if @stream.respond_to?(:sync=)
  @buffer = Buffer.new
  @buffer_size = (options[:buffer_size] || 0)
  template = (options[:template] || DEFAULT_FIRST_LINE_TEMPLATE)
  if template.respond_to?(:call)
    @template = template
  else
    additional_lines = (options[:additional_lines] || DEFAULT_ADDITIONAL_LINES_TEMPLATE)
    @template = Template.new(template, additional_lines: additional_lines, time_format: options[:time_format])
  end
end