Class: EventLoggerRails::Formatters::JSON

Inherits:
ActiveSupport::Logger::SimpleFormatter
  • Object
show all
Defined in:
lib/event_logger_rails/formatters/json.rb

Overview

Writes log entries in JSON format

Instance Method Summary collapse

Instance Method Details

#call(level, timestamp, _progname, message) ⇒ String

Returns the formatted output for logging.

Parameters:

  • level (Symbol)

    The level of the event.

  • timestamp (Time)

    The timestamp of the event.

  • progname (String)

    The name of the logger.

  • message (EventLoggerRails::Message, Hash, String)

    The message containing the data for logging.

Returns:

  • (String)

    The formatted output for logging.



14
15
16
17
# File 'lib/event_logger_rails/formatters/json.rb', line 14

def call(level, timestamp, _progname, message)
  output = Output.new(level:, timestamp:, message:)
  "#{output.to_json}\n"
end