@@ -13,7 +13,7 @@ export const infoLogger = (
13
13
apiKey : string | undefined ,
14
14
...args : unknown [ ]
15
15
) : void => {
16
- logger ( console . info , source , message , apiKey , args ) ;
16
+ logger ( console . info , source , message , apiKey , ... args ) ;
17
17
} ;
18
18
19
19
/**
@@ -29,7 +29,7 @@ export const errorLogger = (
29
29
apiKey : string | undefined ,
30
30
...args : unknown [ ]
31
31
) : void => {
32
- logger ( console . error , source , message , apiKey , args ) ;
32
+ logger ( console . error , source , message , apiKey , ... args ) ;
33
33
} ;
34
34
35
35
/**
@@ -45,7 +45,7 @@ export const warnLogger = (
45
45
apiKey ?: string ,
46
46
...args : unknown [ ]
47
47
) : void => {
48
- logger ( console . warn , source , message , apiKey , args ) ;
48
+ logger ( console . warn , source , message , apiKey , ... args ) ;
49
49
} ;
50
50
51
51
const logger = (
@@ -56,23 +56,22 @@ const logger = (
56
56
...args : unknown [ ]
57
57
) : void => {
58
58
// eslint-disable-next-line no-console
59
- if ( apiKey ) {
60
- logFn (
61
- constructLogMessage (
62
- `[${ anonymizeKey ( apiKey ) } ]` ,
63
- `[${ source } ]` ,
64
- message ,
65
- ...args
66
- )
67
- ) ;
68
- } else {
69
- logFn ( constructLogMessage ( `[${ source } ]` , message , ...args ) ) ;
70
- }
59
+ const anonymizedApiKey = apiKey ? anonymizeKey ( apiKey ) : undefined ;
60
+
61
+ logFn (
62
+ constructLogMessage (
63
+ anonymizedApiKey ? `[${ anonymizedApiKey } ]` : undefined ,
64
+ `[${ source } ]` ,
65
+ message
66
+ ) ,
67
+ ...args
68
+ ) ;
71
69
} ;
72
70
73
71
const constructLogMessage = ( ...args : unknown [ ] ) : string =>
74
72
`${ args
75
73
. flat ( )
74
+ . filter ( ( item ) => item != undefined )
76
75
. map ( ( item : unknown ) => {
77
76
if ( Array . isArray ( item ) && item . length == 0 ) return ;
78
77
return typeof item !== "string" ? JSON . stringify ( item ) : item ;
0 commit comments