Class: LogSinks::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/log_sinks/formatter.rb

Overview

Base class that serializes event to data format acceptable by sink (usually it’s [String])

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



6
7
8
# File 'lib/log_sinks/formatter.rb', line 6

def initialize
  @timestamp_format = '%Y-%m-%dT%H:%M:%S.%6N'
end

Instance Method Details

#call(event) ⇒ Object



10
11
12
13
14
# File 'lib/log_sinks/formatter.rb', line 10

def call(event)
  # rubocop:disable Layout/LineLength
  "#{event.level.to_s[0]}, [#{event.timestamp.strftime(@timestamp_format)} ##{Process.pid}] #{event.level} -- #{event[:progname]}: #{event.message}\n"
  # rubocop:enable Layout/LineLength
end