File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change 11import winston , { format } from 'winston' ;
22import { inspect } from 'util' ;
33
4+ function simpleInspect ( value ) {
5+ if ( typeof value === 'string' ) return value ;
6+ return inspect ( value , { depth : null } ) ;
7+ }
8+
49function formatter ( info ) {
5- const stringifiedRest = inspect (
6- {
7- ...info ,
8- level : undefined ,
9- message : undefined ,
10- splat : undefined
11- } ,
12- { depth : null }
13- ) ;
10+ const splat = info [ Symbol . for ( 'splat' ) ] || [ ] ;
11+ const stringifiedRest = splat . length > 0 ? ` ${ splat . map ( simpleInspect ) . join ( ' ' ) } ` : '' ;
1412
1513 const padding = ( info . padding && info . padding [ info . level ] ) || '' ;
16- if ( stringifiedRest !== '{}' ) {
17- return `${ info . timestamp } ${ info . level } :${ padding } ${ info . message } ${ stringifiedRest } ` ;
18- }
19-
20- return `${ info . timestamp } ${ info . level } :${ padding } ${ info . message } ` ;
14+ return `${ info . timestamp } ${ info . level } :${ padding } ${ info . message } ${ stringifiedRest } ` ;
2115}
2216
2317const logger = winston . createLogger ( {
@@ -26,7 +20,7 @@ const logger = winston.createLogger({
2620 format : format . combine (
2721 format . colorize ( ) ,
2822 format . timestamp ( ) ,
29- format . printf ( formatter )
23+ format . printf ( formatter ) ,
3024 )
3125} ) ;
3226
You can’t perform that action at this time.
0 commit comments