Skip to content

Commit

Permalink
Merge pull request #184 from konecty/feat/conditional-pretty-logs
Browse files Browse the repository at this point in the history
Feature: add option to enable pretty logs
  • Loading branch information
7sete7 authored Nov 6, 2024
2 parents ab71f7b + a50ecdf commit 89aba8c
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 89aba8c

Please sign in to comment.