Class: CMDx::LogFormatters::JSON
- Inherits:
-
Object
- Object
- CMDx::LogFormatters::JSON
- Defined in:
- lib/cmdx/log_formatters/json.rb
Overview
Formats log messages as JSON for structured logging
This formatter converts log entries into JSON format with standardized fields including severity, timestamp, program name, process ID, and formatted message. The output is suitable for log aggregation systems and structured analysis.
Instance Method Summary collapse
-
#call(severity, time, progname, message) ⇒ String
Formats a log entry as a JSON string.
Instance Method Details
#call(severity, time, progname, message) ⇒ String
Formats a log entry as a JSON string
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cmdx/log_formatters/json.rb', line 26 def call(severity, time, progname, ) hash = { severity:, timestamp: time.utc.iso8601(6), progname:, pid: Process.pid, message: Utils::Format.to_log() } ::JSON.dump(hash) << "\n" end |