Files
inventory/inventory-server/shared/logging/logger.js
T

28 lines
541 B
JavaScript

import { pino } from 'pino';
const REDACTED_PATHS = [
'req.headers.authorization',
'req.headers.cookie',
'headers.authorization',
'headers.cookie',
'*.password',
'*.token',
'*.jwt',
];
export function createLogger(options = {}) {
return pino({
level: process.env.LOG_LEVEL ?? 'info',
redact: {
paths: REDACTED_PATHS,
censor: '[REDACTED]',
},
base: {
service: options.service ?? process.env.SERVICE_NAME ?? 'inventory',
},
...options,
});
}
export const logger = createLogger();