Commit ee2d70f 1 parent 91ad0b1 commit ee2d70f Copy full SHA for ee2d70f
File tree 1 file changed +9
-15
lines changed
1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change 1
1
import winston , { format } from 'winston' ;
2
2
import { inspect } from 'util' ;
3
3
4
+ function simpleInspect ( value ) {
5
+ if ( typeof value === 'string' ) return value ;
6
+ return inspect ( value , { depth : null } ) ;
7
+ }
8
+
4
9
function 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 ( ' ' ) } ` : '' ;
14
12
15
13
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 } ` ;
21
15
}
22
16
23
17
const logger = winston . createLogger ( {
@@ -26,7 +20,7 @@ const logger = winston.createLogger({
26
20
format : format . combine (
27
21
format . colorize ( ) ,
28
22
format . timestamp ( ) ,
29
- format . printf ( formatter )
23
+ format . printf ( formatter ) ,
30
24
)
31
25
} ) ;
32
26
You can’t perform that action at this time.
0 commit comments