Class: CMDx::LogFormatters::Logstash
- Inherits:
-
Object
- Object
- CMDx::LogFormatters::Logstash
- Defined in:
- lib/cmdx/log_formatters/logstash.rb
Overview
‘Logger` formatter that produces one JSON line per entry in the shape expected by Logstash (`@version` + `@timestamp`).
Instance Method Summary collapse
-
#call(severity, time, progname, message) ⇒ String
JSON line terminated by ‘“n”`.
Instance Method Details
#call(severity, time, progname, message) ⇒ String
Returns JSON line terminated by ‘“n”`.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cmdx/log_formatters/logstash.rb', line 14 def call(severity, time, progname, ) hash = { severity:, progname:, pid: Process.pid, message: .respond_to?(:to_h) ? .to_h : , "@version" => "1", "@timestamp" => time.utc.iso8601(6) } ::JSON.dump(hash) << "\n" end |