Sha256: dbd246aaac3652c7caba3e5bb80932f9549748d1c1c53fd85bf8ab9c1542e8ae
Contents?: true
Size: 882 Bytes
Versions: 4
Compression:
Stored size: 882 Bytes
Contents
class Logasm module Adapters class LogstashAdapter class Formatter < ::Logger::Formatter HOST = ::Socket.gethostname def initialize(service_name) @service_name = service_name end def call(severity, time, _progname, message) event = build_event(message, severity, time) "#{event.to_json}\n" end private def build_event(metadata, level, time) event = LogStash::Event.new(metadata.merge("@timestamp" => time)) event['application'] = @service_name if @service_name event['level'] = level.downcase event['host'] ||= HOST # In case Time#to_json has been overridden if event.timestamp.is_a?(Time) event.timestamp = event.timestamp.iso8601(3) end event end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems