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

Merged
merge-queue merged 1 commit from aht-204-logline into main 2026-11-26 14:43:37 -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 (no query string), status and ms, with a 5xx logged at error. morgan is gone from the dependencies.
  • The service's 30 console calls become a level, a fixed message and fields. They are in server.js (ready, startup failed, pending migrations), auth.js (get-session failed), the 24 route handlers in cardio, soreness and workouts, and self-check.js. Error stacks and upstream error text go through errorText, which masks with redact and caps at 4 KiB. No session cookie, token or Authorization value is logged.
  • Left on console on purpose: migrations/apply.js and migrations/dry-run.js. Nelson runs these by hand (npm run migrate, npm run migrate:dry-run), and their output is a report for him to read in the terminal, not the service's log. The migrations that run at pod startup (migrations/runner.js) write no lines of their own.
  • 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 web-app and cluster-service suites pass that secret to the image build.
  • 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 soreness routes: one line per request, no query, and a 500 at error with its masked route-error line.

Locally, ci-check passed the backend and frontend checks. The conventions check could not run on this PC because it needs Python, so CI decides that one.

🤖 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` (no query string), `status` and `ms`, with a 5xx logged at error. morgan is gone from the dependencies. - The service's 30 console calls become a level, a fixed message and fields. They are in `server.js` (ready, startup failed, pending migrations), `auth.js` (get-session failed), the 24 route handlers in cardio, soreness and workouts, and `self-check.js`. Error stacks and upstream error text go through `errorText`, which masks with `redact` and caps at 4 KiB. No session cookie, token or Authorization value is logged. - Left on console on purpose: `migrations/apply.js` and `migrations/dry-run.js`. Nelson runs these by hand (`npm run migrate`, `npm run migrate:dry-run`), and their output is a report for him to read in the terminal, not the service's log. The migrations that run at pod startup (`migrations/runner.js`) write no lines of their own. - `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 web-app and cluster-service suites pass that secret to the image build. - `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 soreness routes: one line per request, no query, and a 500 at error with its masked route-error line. Locally, `ci-check` passed the backend and frontend checks. The conventions check could not run on this PC because it needs Python, so CI decides that one. 🤖 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 tofu / apply (push) Has been skipped
Suite web-app / scope (push) Has been skipped
Suite web-app / check-image (push) Has been skipped
Suite web-app / publish (push) Has been skipped
Suite web-app / publish-static (push) Has been skipped
Suite web-app / reused-checks (push) Has been skipped
Suite tofu / check-plan (push) Has been skipped
Suite tofu / reused-checks (push) Has been skipped
Suite cluster-service / check-image (pull_request) Has been skipped
Suite cluster-service / scope (pull_request) Successful in 21s
Checks / check-conventions (pull_request) Successful in 9s
Suite cluster-service / publish (pull_request) Has been skipped
Suite default / scope (pull_request) Successful in 20s
Suite web-app / scope (pull_request) Successful in 22s
Suite web-app / publish (pull_request) Has been skipped
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite tofu / check-plan (pull_request) Has been skipped
Suite tofu / apply (pull_request) Has been skipped
Suite web-app / publish-static (pull_request) Has been skipped
Suite tofu / scope (pull_request) Successful in 18s
Suite default / check-rules (pull_request) Has been skipped
Suite web-app / check-test (frontend) (pull_request) Successful in 1m19s
Suite default / check-fetches (pull_request) Successful in 24s
Suite tofu / reused-checks (pull_request) Successful in 26s
Suite default / reused-checks (pull_request) Successful in 24s
Suite cluster-service / reused-checks (pull_request) Successful in 26s
Suite web-app / check-test (backend) (pull_request) Successful in 1m3s
Suite web-app / check-image (pull_request) Successful in 5m1s
merge-queue landed on main
Suite web-app / reused-checks (pull_request) Successful in 23s
3f1c8f114b
morgan's combined access log becomes one standard `request` line per request
(method, path without the query, status, ms; 5xx at error), and every console call
in the server, auth, routes and self-check becomes a fixed message with fields,
through backend/log.js (@romaine-life/logline 0.1.4 from Forgejo's npm registry).
Error text is masked with redact and capped at 4 KiB. The hand-run migration
scripts (migrations/apply.js, dry-run.js) keep their console report for the person
running them. 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:43:38 -08:00
Sign in to join this conversation.
No description provided.