File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 16
16
" Titanism"
17
17
],
18
18
"dependencies" : {
19
+ "@ladjs/format-util" : " ^1.0.4" ,
19
20
"ansi-colors" : " ^4.1.3" ,
20
21
"clf-date" : " ^0.2.1" ,
22
+ "format-specifiers" : " ^1.0.0" ,
21
23
"iserror" : " ^0.0.2" ,
22
24
"merge-options" : " ^3.0.4" ,
23
25
"ms" : " ^2.1.3" ,
Original file line number Diff line number Diff line change 1
1
const Axe = require ( 'axe' ) ;
2
+ const format = require ( '@ladjs/format-util' ) ;
3
+ const formatSpecifiers = require ( 'format-specifiers' ) ;
2
4
const isError = require ( 'iserror' ) ;
3
- const parseErr = require ( 'parse-err' ) ;
4
5
const mergeOptions = require ( 'merge-options' ) ;
6
+ const parseErr = require ( 'parse-err' ) ;
5
7
const pkg = require ( '../package.json' ) ;
6
8
const {
7
9
isNull,
@@ -48,7 +50,15 @@ class Cabin {
48
50
isFunction ( this . config . logger [ key ] )
49
51
) ) {
50
52
this [ level ] = ( ...args ) => {
51
- if ( args [ 1 ] ) args [ 1 ] = this . parseArg ( args [ 1 ] ) ;
53
+ // support format specifiers
54
+ if (
55
+ typeof args [ 0 ] === 'string' &&
56
+ formatSpecifiers . some ( ( t ) => args [ 0 ] . includes ( t ) ) &&
57
+ args [ 1 ]
58
+ ) {
59
+ args [ 0 ] = format ( args [ 0 ] , args [ 1 ] ) ;
60
+ delete args [ 1 ] ;
61
+ } else if ( args [ 1 ] ) args [ 1 ] = this . parseArg ( args [ 1 ] ) ;
52
62
return this . config . logger [ level ] ( ...Array . prototype . slice . call ( args ) ) ;
53
63
} ;
54
64
}
Original file line number Diff line number Diff line change
1
+ const format = require ( '@ladjs/format-util' ) ;
2
+ const formatSpecifiers = require ( 'format-specifiers' ) ;
1
3
const onFinished = require ( 'on-finished' ) ;
2
4
const parseRequest = require ( 'parse-request' ) ;
3
5
const { isFunction, isUndefined } = require ( './utils' ) ;
@@ -19,6 +21,16 @@ module.exports = function (...args) {
19
21
isFunction ( this . config . logger [ key ] )
20
22
) ) {
21
23
logger [ key ] = ( ...parameters ) => {
24
+ // support format specifiers
25
+ if (
26
+ typeof parameters [ 0 ] === 'string' &&
27
+ formatSpecifiers . some ( ( t ) => parameters [ 0 ] . includes ( t ) ) &&
28
+ parameters [ 1 ]
29
+ ) {
30
+ parameters [ 0 ] = format ( parameters [ 0 ] , parameters [ 1 ] ) ;
31
+ parameters [ 1 ] = undefined ;
32
+ }
33
+
22
34
parameters [ 1 ] = isUndefined ( parameters [ 1 ] )
23
35
? { }
24
36
: this . parseArg ( parameters [ 1 ] ) ;
You can’t perform that action at this time.
0 commit comments