Write the backend's logs as the estate's log line (AHT-204) #99

Merged
merge-queue merged 1 commit from aht-204-logline into main 2026-11-26 14:34:11 -08:00
Owner

Work package: AHT-204, one logging standard across at-home.

The backend's logs become the estate's one log line, the same way auth and chess-tactics moved.

  • morgan's combined access log is removed. requestLog() in backend/log.js replaces it and writes one request line per request:
    • method, path (the full path with no query string), status and ms.
    • caller, the token kind morgan used to write as caller="..." (home device=…, auth human sub=…, auth refused …), still in the line as CLAUDE.md describes, now masked.
    • A 5xx is logged at error.
    • morgan is gone from the dependencies.
  • The 6 console calls in server.js and routes/app.js become a level, a fixed message and fields. These are ready, self-test passed or failed, startup failed, tree read failed and tree save failed. The last two carry the tree id. Error stacks go through errorText, which masks with redact and caps at 4 KiB. No token, cookie or Authorization value is logged.
  • backend/.npmrc points to Forgejo's npm registry, and @romaine-life/logline is pinned at 0.1.4. The Dockerfile copies .npmrc and mounts the FORGEJO_PACKAGES_TOKEN BuildKit secret on npm ci. The image is built by the cluster-service suite, which passes that secret, and runs on the home cluster.
  • backend/log.test.js (new) reads the lines back with logline's parse. It covers absent fields, masking and the cap, and a real Express app with the /fzt router: the full path, no query, caller, 404, and a 500 at error with its masked tree read failed line. --self-test was also run locally, and it writes only standard lines.

🤖 Generated with Claude Code

Work package: [AHT-204](https://openproject.home.romaine.life/wp/AHT-204), one logging standard across at-home. The backend's logs become the estate's one log line, the same way auth and chess-tactics moved. - morgan's combined access log is removed. `requestLog()` in `backend/log.js` replaces it and writes one `request` line per request: - `method`, `path` (the full path with no query string), `status` and `ms`. - `caller`, the token kind morgan used to write as `caller="..."` (`home device=…`, `auth human sub=…`, `auth refused …`), still in the line as CLAUDE.md describes, now masked. - A 5xx is logged at error. - morgan is gone from the dependencies. - The 6 console calls in `server.js` and `routes/app.js` become a level, a fixed message and fields. These are ready, self-test passed or failed, startup failed, tree read failed and tree save failed. The last two carry the tree id. Error stacks go through `errorText`, which masks with `redact` and caps at 4 KiB. No token, cookie or Authorization value is logged. - `backend/.npmrc` points to Forgejo's npm registry, and `@romaine-life/logline` is pinned at 0.1.4. The Dockerfile copies `.npmrc` and mounts the `FORGEJO_PACKAGES_TOKEN` BuildKit secret on `npm ci`. The image is built by the cluster-service suite, which passes that secret, and runs on the home cluster. - `backend/log.test.js` (new) reads the lines back with logline's `parse`. It covers absent fields, masking and the cap, and a real Express app with the `/fzt` router: the full path, no query, `caller`, 404, and a 500 at error with its masked `tree read failed` line. `--self-test` was also run locally, and it writes only standard lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Write the backend's logs as the estate's log line (AHT-204)
All checks were successful
Suite default / reused-checks (pull_request) Successful in 19s
Suite go / reused-checks (pull_request) Successful in 18s
Suite go / check-format (pull_request) Has been skipped
Suite release / home-sync (pull_request) Has been skipped
Suite release / module (pull_request) Has been skipped
Suite release / reserve (pull_request) Has been skipped
Suite release / finalize (pull_request) Has been skipped
Suite go / check-services (pull_request) Has been skipped
Suite web-app / publish-static (pull_request) Has been skipped
Suite release / reused-checks (pull_request) Has been skipped
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite release / scope (pull_request) Successful in 22s
Suite release / build (none, ubuntu-latest) (ubuntu-latest, none) (pull_request) Has been skipped
Suite go / check-test-windows (pull_request) Successful in 1m10s
Suite go / check-test-linux (pull_request) Has been skipped
Suite cluster-service / publish (pull_request) Has been skipped
Suite web-app / scope (pull_request) Successful in 23s
Suite web-app / check-image (pull_request) Has been skipped
Suite web-app / publish (pull_request) Has been skipped
Suite release / check-build (none, ubuntu-latest) (ubuntu-latest, none) (pull_request) Has been skipped
Suite release / check-package (pull_request) Has been skipped
Suite release / dispatch (pull_request) Has been skipped
Suite release / deploy-image (pull_request) Has been skipped
Suite default / check-fetches (pull_request) Successful in 16s
Suite web-app / check-test (backend) (pull_request) Successful in 28s
Suite release / publish (pull_request) Has been skipped
Suite cluster-service / check-image (pull_request) Successful in 50s
merge-queue landed on main
Suite web-app / reused-checks (pull_request) Successful in 19s
Suite cluster-service / reused-checks (pull_request) Successful in 18s
22167494e0
morgan's combined access log becomes one standard `request` line per request
(method, path without the query, status, ms, and the token kind as `caller`; 5xx
at error), and the console calls in server.js and routes/app.js become fixed
messages with fields, through backend/log.js (@romaine-life/logline 0.1.4 from
Forgejo's npm registry). Error text and caller-supplied values are masked with
redact and capped at 4 KiB. log.test.js reads the lines back with logline's parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
merge-queue deleted branch aht-204-logline 2026-11-26 14:34:12 -08:00
Sign in to join this conversation.
No reviewers
No labels
queue
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/fzt-frontend!99
No description provided.