Skip to content

Commit

Permalink
feat: add option to enable pretty logs
Browse files Browse the repository at this point in the history
  • Loading branch information
7sete7 committed Nov 6, 2024
1 parent ab71f7b commit a50ecdf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/imports/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }) });
Expand Down

0 comments on commit a50ecdf

Please sign in to comment.