File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,17 @@ winston.addColors(colors);
3232const format = winston . format . combine (
3333 winston . format . timestamp ( { format : 'YYYY-MM-DD HH:mm:ss:ms' } ) ,
3434 winston . format . colorize ( { all : true } ) ,
35- winston . format . printf (
36- ( info : winston . Logform . TransformableInfo ) => `${ info . timestamp } ${ info . level } : ${ info . message } ` ,
37- ) ,
35+ winston . format . printf ( ( info : winston . Logform . TransformableInfo ) => {
36+ // Handle both string interpolation and object logging
37+ const message = typeof info . message === 'string' ? info . message : JSON . stringify ( info . message ) ;
38+
39+ // If there are additional arguments, format them
40+ const args = ( info [ Symbol . for ( 'splat' ) ] as any [ ] ) || [ ] ;
41+ const formattedMessage =
42+ args . length > 0 ? message . replace ( / % s / g, ( ) => String ( args . shift ( ) || '' ) ) : message ;
43+
44+ return `${ info . timestamp } ${ info . level } : ${ formattedMessage } ` ;
45+ } ) ,
3846) ;
3947
4048// Define which transports the logger must use
You can’t perform that action at this time.
0 commit comments