Class: Makit::Logging::StructuredFormatter Deprecated

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/makit/logging.rb

Overview

Deprecated.

This class is deprecated and will be removed in version 0.2.0. Use Makit::Logging::Logger with Makit::Logging::Sinks::FileSink (formatter: :json) instead.

Structured JSON log formatter

This formatter outputs log messages as JSON objects with structured fields including timestamp, level, message, and program name. Useful for log aggregation systems and machine parsing.

Instance Method Summary collapse

Instance Method Details

#call(severity, time, progname, msg) ⇒ String

Format a log message as JSON

Parameters:

  • severity (String)

    log level (DEBUG, INFO, WARN, ERROR, FATAL)

  • time (Time)

    timestamp of the log message

  • progname (String)

    program name

  • msg (String)

    the log message content

Returns:

  • (String)

    JSON formatted log entry with newline



196
197
198
199
200
201
202
203
204
205
# File 'lib/makit/logging.rb', line 196

def call(severity, time, progname, msg)
  warn "Makit::Logging::StructuredFormatter is deprecated and will be removed in version 0.2.0. Use Makit::Logging::Logger with Makit::Logging::Sinks::FileSink (formatter: :json) instead."
  timestamp = time.strftime("%Y-%m-%d %H:%M:%S.%L")
  {
    timestamp: timestamp,
    level: severity,
    message: msg,
    progname: progname,
  }.to_json + "\n"
end