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();
