Files
homelab-frontend/tasks/0.5-structured-logging.md
T
Story Crater BotandClaude Opus 5 058f11cf2b
CI / Test (push) Canceled after 0s
CI / Vet (push) Canceled after 0s
CI / Build (push) Canceled after 0s
CI / Security (govulncheck) (push) Canceled after 0s
chore: initial commit of Go API gateway
Baseline for the Kong replacement on api.riotpiao.com. Brings the working
tree under version control for the first time: gateway source, the task
board that drives the agent runs, test fixtures, and K8s manifests.

Anchor the gateway ignore rule to the repo root. Unanchored, "gateway"
also matched the cmd/gateway/ source directory, so the program entrypoint
was excluded from every commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-08-19 20:54:34 -07:00

1.3 KiB

0.5 — Structured logging (GREEN)

Phase: 0 — Foundations Stage: GREEN Depends on: 0.1

  • Logs are emitted as structured records with a consistent field set, one record per line
  • Every request log carries at least: route, upstream, method, path, status, duration
  • Every rejected request is logged with an explicit machine-readable reason field
  • Request bodies are never logged, in whole or in part
  • Authorization header values, bearer tokens, API keys and JWKS material are never logged, not even truncated or hashed-with-prefix
  • Log level is configurable, and no level unlocks body or token logging
  • A test asserts a rejected request produces exactly one record containing the reason and containing no token substring

Rejections come from several layers — unknown model, body too large, auth failure, concurrency limit — and the reason field is what makes them countable later. The model API carries prompts that are user content and tokens that are credentials; neither belongs in a log line.

Verify

go test ./internal/logging/... ./internal/server/... -run 'TestLog' -v
# expected: passes — captured log output for a rejected request contains the reason
# field and does not contain the request body or the bearer token used