Files
owenrees 202b9b1f6a Add structured production logging (#105, #107) (#141)
* Update README.md

* Add structured JSON production logging (#105)

* Log requests and background failures (#107)

* Document production logging and the VPS runbook
2026-11-10 22:00:05 +01:00

26 lines
654 B
Elixir

defmodule ChesstrainerWeb.Plugs.PutRequestId do
@moduledoc """
Copies `Plug.RequestId`'s request id into the session.
LiveView processes handle later events after the original HTTP request has
finished. Keeping the id in the session lets `UserAuth.mount_current_scope/2`
put it into `Logger.metadata/1`, so LiveView logs remain correlatable with the
request that mounted them.
"""
@behaviour Plug
import Plug.Conn
@impl true
def init(opts), do: opts
@impl true
def call(conn, _opts) do
case conn.assigns[:request_id] do
nil -> conn
request_id -> put_session(conn, :request_id, request_id)
end
end
end