File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 11import { pino , Logger } from 'pino' ;
2- import pretty from 'pino-pretty' ;
2+ import { prettyFactory } from 'pino-pretty' ;
3+
34import { LogLevel } from './types' ;
45
5- export const createLogger = ( level : LogLevel ) : Logger =>
6- pino (
6+ export const createLogger = ( level : LogLevel ) : Logger => {
7+ const prettify = prettyFactory ( { sync : true } ) ;
8+ // Configure custom stream that forwards pretty message to console
9+ // to address issues with pino pretty and Jest
10+ // Thanks to https://github.com/pinojs/pino-pretty/issues/480#issuecomment-2271709217 for the solution
11+ return pino (
712 {
813 level : level . toLowerCase ( ) ,
914 } ,
10- pretty ( { sync : true } )
15+ {
16+ write ( data : unknown ) {
17+ console . log ( prettify ( data ) ) ;
18+ } ,
19+ }
1120 ) ;
21+ } ;
You can’t perform that action at this time.
0 commit comments