Repository navigation
feat(server): log healthcheck at debug level, add logLevel setting - #606
Conversation
Replace fuego's request logging with an access log middleware that keeps its fields and X-Request-ID but logs the healthcheck polled by Docker at debug level. Add logLevel (OCAP_LOGLEVEL, default info): the slog handler was created without options, so debug records were always dropped.
Merging this branch will decrease overall coverage
Coverage detailsCompared to commit 078e68e (run #43493631896)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files:
|
|
Ratatoskr reviewed this pull request. Approved on Finished 2026-11-14 00:01 UTC. |
fank
left a comment
There was a problem hiding this comment.
APPROVE — 0 blocking findings.
Review details
Reviewed head 1db4f51e48526639c41e373b4c9a5cff6e196370 against the base, including Fuego v0.21.0 middleware registration and existing streaming handlers. No actionable correctness or safety defects found.
Optional test improvement: internal/server/accesslog_test.go:40–46 implements its own 404 handler rather than exercising an unmatched Fuego route. An integration test covering the wiring in cmd/ocap-webserver/main.go:82–83, a non-empty URL prefix, and exactly one outgoing log would pin the global-middleware/no-duplicates behavior; the current unit tests do not protect that wiring.
Verification (Go 1.27.3 from the local module-cache toolchain, added to PATH):
go test ./internal/server -run 'TestAccessLog|TestNewSetting_Logging' -count=1— passed.go test ./internal/server ./cmd/...— command package passed; server suite failed because the local CGO-disabled SQLite driver is a stub.CGO_ENABLED=1 go test ./internal/server ./cmd/...— build unavailable: C compilergccis missing. This is an environment limitation, not an identified PR regression.- GitHub test and coverage checks passed.
Discussions: GraphQL enumeration returned no review threads (no further pages); none to resolve, leave open, or skip. Checkout remained unchanged. No UI changes requiring visual verification.
* feat(server): log real client IP behind trusted reverse proxies Add trustedProxies (OCAP_TRUSTEDPROXIES) and remoteIPHeaders (OCAP_REMOTEIPHEADERS, default X-Forwarded-For, X-Real-IP). When the direct peer is a trusted proxy, RemoteAddr is replaced with the client address from the headers, X-Forwarded-For read right to left so entries the client sent itself are skipped, and the access log adds the proxy as proxy_addr. No proxy is trusted by default, so headers are ignored. * docs: explain trusting Cloudflare behind another reverse proxy * refactor(server): drop proxy_addr from the access log With a single reverse proxy it is the same address on every line. * style: gofmt realip_test.go * fix(server): match IPv4-mapped trusted proxy prefixes Addresses are unmapped before matching, but a trusted proxy given as an IPv4-mapped CIDR (::ffff:172.18.0.0/112) stayed an IPv6 prefix and never matched. Convert it to the equivalent IPv4 prefix; reject mapped prefixes shorter than /96, which cover more than the mapped range.
Summary
Docker polls
/api/healthcheckevery 30s, and each poll was logged at info level asoutgoing response, flooding the logs.AccessLogMiddleware. It keeps fuego's fields andX-Request-IDhandling but logs<prefixURL>/api/healthcheckat debug level. Fuego's logger can't change the level per path.logLevel/OCAP_LOGLEVEL(debug,info,warn,error; defaultinfo). The slog handler was created without options, so debug records, including fuego'sincoming request, were always dropped.A follow-up PR (stacked on this one) logs the real client IP behind reverse proxies.
Test plan
go test ./internal/server ./cmd/...info, other requests logged once (no duplicates from fuego)