@@ -20,67 +20,75 @@ function addMessageToTraceSpan(
20
20
* @param source the context where the log originated from (usually the function name)
21
21
* @param message the message of the log
22
22
* @param apiKey the refreshToken
23
+ * @param integrationUserId platypus user id
23
24
* @param args additional data, will be stringified and appended
24
25
*/
25
26
export const infoLogger = (
26
27
source : string ,
27
28
message : string ,
28
29
apiKey ?: string ,
30
+ integrationUserId ?: string ,
29
31
...args : unknown [ ]
30
32
) : void => {
31
- addMessageToTraceSpan ( 'log' , message , args ) ;
33
+ addMessageToTraceSpan ( 'log' , message , [ ... args , integrationUserId ] ) ;
32
34
33
- logger ( console . info , source , message , apiKey , ...args ) ;
35
+ logger ( console . info , source , message , apiKey , integrationUserId , ...args ) ;
34
36
} ;
35
37
36
38
/**
37
39
* Logging function equivalent to console.error
38
40
* @param source the context where the log originated from (usually the function name)
39
41
* @param message the message of the log
40
42
* @param apiKey the refreshToken
43
+ * @param integrationUserId platypus user id
41
44
* @param args additional data, will be stringified and appended
42
45
*/
43
46
export const errorLogger = (
44
47
source : string ,
45
48
message : string ,
46
49
apiKey ?: string ,
50
+ integrationUserId ?: string ,
47
51
...args : unknown [ ]
48
52
) : void => {
49
- addMessageToTraceSpan ( 'error' , message , args ) ;
53
+ addMessageToTraceSpan ( 'error' , message , [ ... args , integrationUserId ] ) ;
50
54
51
- logger ( console . error , source , message , apiKey , ...args ) ;
55
+ logger ( console . error , source , message , apiKey , integrationUserId , ...args ) ;
52
56
} ;
53
57
54
58
/**
55
59
* Logging function equivalent to console.warn
56
60
* @param source the context where the log originated from (usually the function name)
57
61
* @param message the message of the log
58
62
* @param apiKey the refreshToken
63
+ * @param integrationUserId platypus user id
59
64
* @param args additional data, will be stringified and appended
60
65
*/
61
66
export const warnLogger = (
62
67
source : string ,
63
68
message : string ,
64
69
apiKey ?: string ,
70
+ integrationUserId ?: string ,
65
71
...args : unknown [ ]
66
72
) : void => {
67
- addMessageToTraceSpan ( 'warn' , message , args ) ;
73
+ addMessageToTraceSpan ( 'warn' , message , [ ... args , integrationUserId ] ) ;
68
74
69
- logger ( console . warn , source , message , apiKey , ...args ) ;
75
+ logger ( console . warn , source , message , apiKey , integrationUserId , ...args ) ;
70
76
} ;
71
77
72
78
const logger = (
73
79
logFn : ( message ?: any , ...optionalParams : any [ ] ) => void ,
74
80
source : string ,
75
81
message : string ,
76
82
apiKey : string | undefined ,
83
+ integrationUserId : string | undefined ,
77
84
...args : unknown [ ]
78
85
) : void => {
79
86
// eslint-disable-next-line no-console
80
87
const anonymizedApiKey = apiKey ? anonymizeKey ( apiKey ) : undefined ;
81
88
82
89
const formatedMessage = constructLogMessage (
83
90
anonymizedApiKey ? `[${ anonymizedApiKey } ]` : undefined ,
91
+ integrationUserId ? `[${ integrationUserId } ]` : undefined ,
84
92
`[${ source } ]` ,
85
93
message ,
86
94
) ;
@@ -91,7 +99,7 @@ const logger = (
91
99
logFn (
92
100
JSON . stringify ( {
93
101
message : formatedMessage ,
94
- data : args ,
102
+ data : { ... args , integrationUserId } ,
95
103
} ) ,
96
104
) ;
97
105
}
0 commit comments