1
1
import { anonymizeKey } from "./anonymize-key" ;
2
2
3
+ /**
4
+ * Logging function equivalent to console.log
5
+ * @param source the context where the log originated from (usually the function name)
6
+ * @param message the message of the log
7
+ * @param apiKey the refreshToken
8
+ * @param args additional data, will be stringified and appended
9
+ */
3
10
export const infoLogger = (
4
11
source : string ,
5
12
message : string ,
@@ -11,18 +18,23 @@ export const infoLogger = (
11
18
console . log (
12
19
constructLogMessage (
13
20
`[${ anonymizeKey ( apiKey ) } ]` ,
14
- `[${ source . toUpperCase ( ) } ]` ,
21
+ `[${ source } ]` ,
15
22
message ,
16
23
args
17
24
)
18
25
) ;
19
26
} else {
20
- console . log (
21
- constructLogMessage ( `[${ source . toUpperCase ( ) } ]` , message , args )
22
- ) ;
27
+ console . log ( constructLogMessage ( `[${ source } ]` , message , args ) ) ;
23
28
}
24
29
} ;
25
30
31
+ /**
32
+ * Logging function equivalent to console.error
33
+ * @param source the context where the log originated from (usually the function name)
34
+ * @param message the message of the log
35
+ * @param apiKey the refreshToken
36
+ * @param args additional data, will be stringified and appended
37
+ */
26
38
export const errorLogger = (
27
39
source : string ,
28
40
message : string ,
@@ -34,18 +46,23 @@ export const errorLogger = (
34
46
console . error (
35
47
constructLogMessage (
36
48
`[${ anonymizeKey ( apiKey ) } ]` ,
37
- `[${ source . toUpperCase ( ) } ]` ,
49
+ `[${ source } ]` ,
38
50
message ,
39
51
args
40
52
)
41
53
) ;
42
54
} else {
43
- console . error (
44
- constructLogMessage ( `[${ source . toUpperCase ( ) } ]` , message , args )
45
- ) ;
55
+ console . error ( constructLogMessage ( `[${ source } ]` , message , args ) ) ;
46
56
}
47
57
} ;
48
58
59
+ /**
60
+ * Logging function equivalent to console.warn
61
+ * @param source the context where the log originated from (usually the function name)
62
+ * @param message the message of the log
63
+ * @param apiKey the refreshToken
64
+ * @param args additional data, will be stringified and appended
65
+ */
49
66
export const warnLogger = (
50
67
source : string ,
51
68
message : string ,
@@ -57,15 +74,13 @@ export const warnLogger = (
57
74
console . warn (
58
75
constructLogMessage (
59
76
`[${ anonymizeKey ( apiKey ) } ]` ,
60
- `[${ source . toUpperCase ( ) } ]` ,
77
+ `[${ source } ]` ,
61
78
message ,
62
79
args
63
80
)
64
81
) ;
65
82
} else {
66
- console . warn (
67
- constructLogMessage ( `[${ source . toUpperCase ( ) } ]` , message , args )
68
- ) ;
83
+ console . warn ( constructLogMessage ( `[${ source } ]` , message , args ) ) ;
69
84
}
70
85
} ;
71
86
0 commit comments