27 lines
1.3 KiB
Markdown
27 lines
1.3 KiB
Markdown
# 0.5 — Structured logging (GREEN)
|
|||
|
|
|
||
|
|
Phase: 0 — Foundations
|
||
|
|
Stage: GREEN
|
||
|
|
Depends on: [0.1](0.1-module-and-entrypoint.md)
|
||
|
|
|
||
|
|
- [ ] 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
|
||
|
|
|
||
|
|
```bash
|
||
|
|
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
|
||
|
|
```
|