feat(logging): ~2-month container rotation, ISO timestamps, level names
Build & push images / images (push) Successful in 2m54s
CI / check (push) Successful in 41s

Operator asked for bounded container logs (~2 months of history), human-
readable timestamps, and clarity on levels. Levels already existed (LOG_LEVEL
env → pino, default info; warn+ teed into app_logs, queryable at /setup/logs)
— the "level":30 / epoch-ms "time" in docker logs were pino defaults.

- server.ts logger: stamp ISO-8601 UTC time (timestamp fn) and level NAMES
  (formatters.level) so `docker logs` reads human.
- log-service.ts pinoDbStream: accept BOTH level encodings (name + numeric) —
  the label switch would otherwise have silently stopped warn+ persistence
  into app_logs. New log-service-stream.test.ts pins both encodings, the
  info-stays-stdout-only rule, and the never-throws fallback.
- docker-compose.prod.yml: json-file caps resized from 10m×3 (≈30 MB — days,
  not months) to ≈2 months by volume: server 20m×30, vision 20m×10, proxy
  10m×5. json-file rotates by SIZE; time-based isn't a driver feature —
  comment says to revisit if `docker logs` holds under ~60 days.
- app_logs retention default aligned 30→60 days (LOG_RETENTION_DAYS still
  overrides).

Wiki: app-logs.md gains the container-log store section (rotation, format,
LOG_LEVEL knob) + retention update; log.md entry.

Suite 282 green.

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
2026-07-04 19:47:53 +02:00
parent 43c1f45e29
commit c21babf293
6 changed files with 120 additions and 15 deletions
+13 -5
View File
@@ -26,11 +26,12 @@ services:
- caddy-config:/config
depends_on:
- server
# ≈2 months (see the server note): Caddy logs errors only — 10 MB × 5 is plenty.
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
max-file: "5"
server:
restart: always
@@ -73,11 +74,17 @@ services:
- /dev/usb:/dev/usb
device_cgroup_rules:
- "c 180:* rmw"
# LOG ROTATION (2026-07-04). Docker's json-file driver rotates by SIZE, not time —
# these caps are sized to hold ≈2 MONTHS at observed booth rates (the operator's
# chosen diagnostic window; revisit if `docker logs` shows less than ~60 days of
# history). Server gets the most (request + device chatter): 20 MB × 30 = 600 MB
# ceiling. NB: `docker logs` only reaches back as far as these files. The queryable
# warn+ store (app_logs, /setup/logs) has its own matching 60-day retention.
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
max-size: "20m"
max-file: "30"
vision:
restart: always
@@ -89,11 +96,12 @@ services:
VISION_RECOGNIZER: fast_alpr
ports:
- "127.0.0.1:8089:8089"
# ≈2 months (see the server note): vision logs less — 20 MB × 10 = 200 MB ceiling.
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
max-size: "20m"
max-file: "10"
volumes:
caddy-data: