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({
|
const logger = pino({
|
||||||
level: isProduction ? 'info' : 'debug',
|
level: isProduction ? 'info' : 'debug',
|
||||||
// Format timestamp en ISO 8601 lisible en prod
|
timestamp: pino.stdTimeFunctions.isoTime,
|
||||||
timestamp: () => `,"time":"${new Date().toISOString()}"`,
|
|
||||||
...(isProduction
|
...(isProduction
|
||||||
? {
|
? {
|
||||||
// En prod, utiliser pino-pretty aussi pour des logs lisibles
|
// In production, use simple JSON output without worker threads
|
||||||
transport: {
|
// This avoids worker.js module resolution issues in Docker/Next.js
|
||||||
target: 'pino-pretty',
|
formatters: {
|
||||||
options: {
|
level: (label) => {
|
||||||
colorize: true,
|
return { level: label.toUpperCase() };
|
||||||
translateTime: 'SYS:dd/mm/yyyy HH:MM:ss',
|
},
|
||||||
ignore: 'pid,hostname',
|
log: (object) => {
|
||||||
singleLine: false,
|
// 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,
|
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)
|
// Prevent memory leaks in development (Node.js runtime only)
|
||||||
|
|||||||
Reference in New Issue
Block a user