Class: CMDx::LogFormatters::KeyValue
- Inherits:
-
Object
- Object
- CMDx::LogFormatters::KeyValue
- Defined in:
- lib/cmdx/log_formatters/key_value.rb
Overview
‘Logger` formatter that emits `key=value.inspect` pairs on a single line. Hash-like messages (including Result) are flattened into the top-level `message` field via `#to_h`.
Instance Method Summary collapse
-
#call(severity, time, progname, message) ⇒ String
Single-line key=value line terminated by ‘“n”`.
Instance Method Details
#call(severity, time, progname, message) ⇒ String
Returns single-line key=value line terminated by ‘“n”`.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cmdx/log_formatters/key_value.rb', line 15 def call(severity, time, progname, ) hash = { severity:, timestamp: time.utc.iso8601(6), progname:, pid: Process.pid, message: .respond_to?(:to_h) ? .to_h : } hash.map { |k, v| "#{k}=#{v.inspect}" }.join(" ") << "\n" end |