Summary
- Add GATEKEEPER_REQUEST_LOGGING=true to log every request with method, path, headers (as JSON), status, and latency_ms
- Add GATEKEEPER_LOG_FORMAT=json to switch all log output (requests, errors, rate limits, everything) to JSON — consistent with PDS logs for cross-service tracing
- Both are off by default — existing behavior unchanged
Env vars
┌────────────────────────────┬─────────┬────────────────────────────────────────────────────────┐ │ Var │ Default │ Description │ ├────────────────────────────┼─────────┼────────────────────────────────────────────────────────┤ │ GATEKEEPER_REQUEST_LOGGING │ false │ Enable per-request logging │ ├────────────────────────────┼─────────┼────────────────────────────────────────────────────────┤ │ GATEKEEPER_LOG_FORMAT │ fmt │ Set to json for structured JSON output across all logs │ └────────────────────────────┴─────────┴────────────────────────────────────────────────────────┘
Test plan
- cargo test — 26 tests pass
- Without env vars: no change in log output
- GATEKEEPER_REQUEST_LOGGING=true: request logs appear in current format
- GATEKEEPER_LOG_FORMAT=json: all logs switch to JSON, headers parseable with jq
- Both combined: per-request JSON logs with searchable IP across LB/gatekeeper/PDS
Had some changes but closed here https://tangled.org/baileytownsend.dev/pds-gatekeeper/pulls/15/round/1
Thank you for the PR! The headers are a JSON string, could not work around that but should be able to parse with JQ and should hopefully be better than nothing