PhoenixReplay.Capture.Logs (PhoenixReplay v0.6.2)

Copy Markdown View Source

Records log messages in the session of the process that logged them.

config :phoenix_replay, logs: [level: :info, metadata: [:request_id]]

Options

  • :level — the lowest level recorded. Defaults to :info. Messages below the :logger primary level are never emitted at all.
  • :metadata — Logger metadata keys to keep. Defaults to [].
  • :limit — log messages recorded per session. Defaults to 1_000.

This is a :logger handler. :logger calls handlers in the process that logs, so a message belongs to the session of that process, or of the first of its $callers that has one, as for PhoenixReplay.Capture.TelemetryEvents. Messages are formatted on one line, their metadata goes through the session's PhoenixReplay.Sanitizer, and each is recorded as a :log event. Their text is masked when the recording is saved, by the session's PhoenixReplay.Redactor.

:logger removes a handler that raises, so failures are reported with [:phoenix_replay, :collector, :exception] instead.

Summary

Functions

Adds the :logger handler when :logs is configured. Called by PhoenixReplay.Capture.Handlers.

Removes the :logger handler, if added.

The :logger handler callback: records event in the session of the process that logged it, or of the LiveView that started it.

Functions

attach(config, id \\ __MODULE__)

@spec attach(PhoenixReplay.Config.t(), atom()) :: :ok | {:error, term()}

Adds the :logger handler when :logs is configured. Called by PhoenixReplay.Capture.Handlers.

detach(id \\ __MODULE__)

@spec detach(atom()) :: :ok

Removes the :logger handler, if added.

log(event, map)

@spec log(:logger.log_event(), :logger.handler_config()) :: :ok

The :logger handler callback: records event in the session of the process that logged it, or of the LiveView that started it.