import pino from "pino"; // Structured JSON logger for Node.js server code (server components, server actions, // background workers). NOT available in the Edge runtime (middleware) — use // console.log with JSON.stringify there instead. // // Secrets are never passed as log fields. Any field named `password`, `secret`, // `token`, or `key` is explicitly excluded by callers. Sensitive env vars // (AUTH_SECRET, VAPID_PRIVATE_KEY, etc.) must not appear in log payloads. // // Log level is controlled by the LOG_LEVEL env var (default: info). // In development, pino-pretty formats output with colour for readability. // In production, single-line JSON goes to stdout and is collected by Docker. const level = process.env.LOG_LEVEL ?? "info"; const logger = pino( { level, base: { pid: undefined, hostname: undefined }, timestamp: pino.stdTimeFunctions.isoTime, }, process.env.NODE_ENV === "production" ? undefined : pino.transport({ target: "pino-pretty", options: { colorize: true } }), ); export default logger;