Logging
How services write logs.
- Log through pino, never
console. Takeloggerfrom@openperf/server/loggingand make one child per component, named in kebab-case:logger.child({ module: "ingest-drainer" }). Inapi, use Nest’sLogger, but never itslog()level. - Pass fields first and a static message second, with errors as
err:log.error({ table, err: error }, "Draining paused"). - A request writes one record when it ends. Add facts to it instead of logging again:
PinoLogger.assign()in Nest apps,assignLogContext()in Bun apps. A failed request adds its error there aserr. - Only an app’s
main.tsconfigures logging. Library code takes no logger and no callback that only logs. - Wrap pg-boss handlers in
handleJobsfrom@openperf/server/jobs, so failures are logged once with theirqueueandjobId. - In tests, assert logs with
recordLogs()from@openperf/server/logging/testing.