Files
dmg 86c87153b4
CI / validate (push) Successful in 4m55s
Release / release (push) Successful in 9m46s
feat(logging): add structured server diagnostics
2026-08-01 17:37:52 -04:00

36 lines
745 B
TypeScript

import pino, { type DestinationStream, type Logger } from "pino";
const redactedPaths = [
"apiKey",
"authorization",
"password",
"token",
"*.apiKey",
"*.authorization",
"*.password",
"*.token",
"headers.authorization",
"req.headers.authorization",
];
export function createLogger(
service: string,
options: { destination?: DestinationStream } = {},
): Logger {
return pino(
{
level: process.env.LOG_LEVEL?.trim() || "info",
base: {
service,
environment: process.env.NODE_ENV ?? "development",
version: process.env.APP_VERSION ?? "development",
},
redact: {
paths: redactedPaths,
censor: "[Redacted]",
},
},
options.destination,
);
}