/** * apps/worker — structured logging (pino). * * `getLogger(module)` returns a child logger bound to a module name so every * line carries context (`mod` field) without manual tagging. In development * the pretty transport is used; in production plain JSON (one line per event) * for log shippers. */ import pino, { type Logger } from "pino"; const isDev = (typeof process.env.NODE_ENV === "undefined" ? "development" : process.env.NODE_ENV) !== "production"; const base = pino({ level: process.env.LOG_LEVEL ?? (isDev ? "debug" : "info"), base: { svc: "factory-worker" }, timestamp: pino.stdTimeFunctions.isoTime, ...(isDev ? { transport: { target: "pino-pretty", options: { colorize: true, translateTime: "SYS:HH:MM:ss", ignore: "pid,hostname,svc" } } } : {}) }); const children = new Map(); /** Get (or create) a child logger for a module/processor name. */ export function getLogger(module: string): Logger { let child = children.get(module); if (!child) { child = base.child({ mod: module }); children.set(module, child); } return child; } export type { Logger };