Zexbox.Logging (Zexbox v1.8.0)

Copy Markdown View Source

Module for logging events in Zexbox.

Summary

Functions

Attaches Telemetry handlers for Phoenix controller events.

Returns a JSON :logger formatter with Zappi defaults, for use in config/runtime.exs. Requires the optional :logger_json dependency

Functions

attach_controller_logs!()

@spec attach_controller_logs!() :: :ok

Attaches Telemetry handlers for Phoenix controller events.

This function sets up handlers for the [:phoenix, :endpoint, :stop] and [:phoenix, :endpoint, :start] events. The handlers are named "phoenix_controller_logs_stop" and "phoenix_controller_logs_start", both of which use the LogHandler.handle_event/4 function to process the events.

Examples

iex> Logging.attach_controller_logs()
:ok
iex> Logging.attach_controller_logs()
** (RuntimeError) event already exists

json_formatter_config(opts \\ [])

@spec json_formatter_config(keyword()) :: {module(), map()}

Returns a JSON :logger formatter with Zappi defaults, for use in config/runtime.exs. Requires the optional :logger_json dependency:

config :logger, :default_handler,
  formatter: Zexbox.Logging.json_formatter_config()

See Zexbox.Logging.JsonFormatter.config/1 for options.