refactor: update logger configuration to use standard ISO timestamps and simplify production output format for better readability
This commit is contained in:
@@ -4,18 +4,29 @@ const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
const logger = pino({
|
||||
level: isProduction ? 'info' : 'debug',
|
||||
// Format timestamp en ISO 8601 lisible en prod
|
||||
timestamp: () => `,"time":"${new Date().toISOString()}"`,
|
||||
timestamp: pino.stdTimeFunctions.isoTime,
|
||||
...(isProduction
|
||||
? {
|
||||
// En prod, utiliser pino-pretty aussi pour des logs lisibles
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: 'SYS:dd/mm/yyyy HH:MM:ss',
|
||||
ignore: 'pid,hostname',
|
||||
singleLine: false,
|
||||
// In production, use simple JSON output without worker threads
|
||||
// This avoids worker.js module resolution issues in Docker/Next.js
|
||||
formatters: {
|
||||
level: (label) => {
|
||||
return { level: label.toUpperCase() };
|
||||
},
|
||||
log: (object) => {
|
||||
// Format readable timestamp in production
|
||||
if (object.time && (typeof object.time === 'string' || typeof object.time === 'number')) {
|
||||
const date = new Date(object.time);
|
||||
object.time = date.toLocaleString('fr-FR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
}
|
||||
return object;
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -29,12 +40,12 @@ const logger = pino({
|
||||
singleLine: true,
|
||||
},
|
||||
},
|
||||
formatters: {
|
||||
level: (label) => {
|
||||
return { level: label.toUpperCase() };
|
||||
},
|
||||
},
|
||||
}),
|
||||
formatters: {
|
||||
level: (label) => {
|
||||
return { level: label.toUpperCase() };
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Prevent memory leaks in development (Node.js runtime only)
|
||||
|
||||
Reference in New Issue
Block a user