pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

Add support for sync: true as option #297

Closed mcollina closed 2 years ago

mcollina commented 2 years ago

Fixes: https://github.com/pinojs/pino-pretty/issues/296

mcollina commented 2 years ago

cc @onkeltem

OnkelTem commented 2 years ago

Great, thanks. It works:

import pino from 'pino';
import pretty from 'pino-pretty';
const logger = pino(pretty({sync: true}));
logger.info('Line 1');
console.log('Line 1');
logger.info('Line 2');
console.log('Line 2');
logger.info('Line 3');
console.log('Line 3');

Output:

$ npx ts-node log-test.ts 
[1642734910384] INFO (15467 on fractal): Line 1
Line 1
[1642734910386] INFO (15467 on fractal): Line 2
Line 2
[1642734910386] INFO (15467 on fractal): Line 3
Line 3

Before it was:

$ npx ts-node log-test.ts 
Line 1
Line 2
Line 3
[1642735523945] INFO (19553 on fractal): Line 1
[1642735523946] INFO (19553 on fractal): Line 2
[1642735523946] INFO (19553 on fractal): Line 3