From a50ecdf9cb6ffd3c553abe13d988b4c228f9b46f Mon Sep 17 00:00:00 2001 From: Leonardo Viva Date: Wed, 6 Nov 2024 16:56:52 -0300 Subject: [PATCH] feat: add option to enable pretty logs --- src/imports/utils/logger.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/imports/utils/logger.ts b/src/imports/utils/logger.ts index 82a7b79d..e82d2076 100644 --- a/src/imports/utils/logger.ts +++ b/src/imports/utils/logger.ts @@ -4,7 +4,13 @@ import pretty from 'pino-pretty'; const level = (process.env.LOG_LEVEL || 'info') as pino.Level; -const stream: pino.StreamEntry[] = [{ level, stream: pretty({ colorize: true, translateTime: 'SYS:standard' }) }]; +const stream: pino.StreamEntry[] = []; + +if (process.env.LOG_PRETTY === 'true') { + stream.push({ level, stream: pretty({ colorize: true, translateTime: 'SYS:standard' }) }); +} else { + stream.push({ level, stream: process.stdout }); +} if (process.env.LOG_TO_FILE) { stream.push({ level, stream: fs.createWriteStream(process.env.LOG_TO_FILE, { flags: 'a' }) });