Tlm.LoggerHandler (tlm v0.1.0)

Copy Markdown

An Erlang :logger handler that reports crashes and records breadcrumbs.

Elixir logs every crash with a crash_reason: processes, Tasks, GenServers, and the errors Plug and Phoenix (LiveView included) report for a request. Those become events. Everything else at info level and above becomes a breadcrumb of the process that logged it.

A crash reason logged without a stacktrace (DBConnection logs each failed reconnect so) gets one frame instead: the call that logged it. The event's message is the logged line, which often says more than the exception (which pool, which process), and its tags are the line's plain metadata values (strings, atoms, numbers, booleans) and domain.

Exceptions that Plug maps to a 4xx status (Ecto.NoResultsError, Phoenix.Router.NoRouteError and the like) are the client's mistake, not a bug, so they aren't reported, even when they crash a LiveView.

The handler runs in the process that logged, so it never lets an error of its own escape into the app.

Summary

Functions

Adds the handler. Options: :id (default :tlm), :sender (default Tlm.Sender).

Functions

attach(opts \\ [])

Adds the handler. Options: :id (default :tlm), :sender (default Tlm.Sender).