Class: ExternalLoggerInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Overview

Note:

This class does not exist at runtime and is used for documentation purposes only. Do not inherit external loggers from it.

Instance Method Summary collapse

Instance Method Details

#call(severity:, tags:, context:, message:, request_info:) ⇒ Object

Called whenever a log entry is created.

Rage automatically detects which parameters your external logger’s #call method accepts, and only passes those parameters. You can omit any of the described parameters in your implementation.

Examples:

Rage.configure do
  config.logger = proc do |severity:, tags:, context:, message:, request_info:|
    data = context.merge(tags:)

    if request_info
      data[:path] = request_info[:env]["PATH_INFO"]
      MyLoggingSDK.info("Request completed", data)
    else
      MyLoggingSDK.public_send(severity, message, data)
    end
  end
end

Parameters:

  • severity (:debug, :info, :warn, :error, :fatal, :unknown)

    the log severity

  • tags (Array)

    the log tags submitted via Rage::Logger#tagged. The first tag is always the request ID

  • context (Hash)

    the log context submitted via Rage::Logger#with_context

  • message (String, nil)

    the log message. For request logs generated by Rage, this is always nil

  • request_info (Hash, nil)

    request-specific information. The value is nil for non-request logs; for request logs, contains the following keys:

Options Hash (request_info:):

  • :env (Hash)

    the Rack env object

  • :params (Hash)

    the request parameters

  • :response (Array)

    the Rack response object

  • :duration (Float)

    the duration of the request in milliseconds



29
30
# File 'lib/rage/configuration.rb', line 29

def call(severity:, tags:, context:, message:, request_info:)
end