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
This commit is contained in:
2026-11-10 22:00:05 +01:00
committed by GitHub
parent f8897fa5ae
commit 202b9b1f6a
20 changed files with 1380 additions and 15 deletions
@@ -0,0 +1,25 @@
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