feat(logging): add structured server diagnostics
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user