Skip to content

Commit 45f414a

Browse files
committed
🚧 Zwico
1 parent 1d7396f commit 45f414a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

‎src/util/logger.util.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,67 +20,75 @@ function addMessageToTraceSpan(
2020
* @param source the context where the log originated from (usually the function name)
2121
* @param message the message of the log
2222
* @param apiKey the refreshToken
23+
* @param integrationUserId platypus user id
2324
* @param args additional data, will be stringified and appended
2425
*/
2526
export const infoLogger = (
2627
source: string,
2728
message: string,
2829
apiKey?: string,
30+
integrationUserId?: string,
2931
...args: unknown[]
3032
): void => {
31-
addMessageToTraceSpan('log', message, args);
33+
addMessageToTraceSpan('log', message, [...args, integrationUserId]);
3234

33-
logger(console.info, source, message, apiKey, ...args);
35+
logger(console.info, source, message, apiKey, integrationUserId, ...args);
3436
};
3537

3638
/**
3739
* Logging function equivalent to console.error
3840
* @param source the context where the log originated from (usually the function name)
3941
* @param message the message of the log
4042
* @param apiKey the refreshToken
43+
* @param integrationUserId platypus user id
4144
* @param args additional data, will be stringified and appended
4245
*/
4346
export const errorLogger = (
4447
source: string,
4548
message: string,
4649
apiKey?: string,
50+
integrationUserId?: string,
4751
...args: unknown[]
4852
): void => {
49-
addMessageToTraceSpan('error', message, args);
53+
addMessageToTraceSpan('error', message, [...args, integrationUserId]);
5054

51-
logger(console.error, source, message, apiKey, ...args);
55+
logger(console.error, source, message, apiKey, integrationUserId, ...args);
5256
};
5357

5458
/**
5559
* Logging function equivalent to console.warn
5660
* @param source the context where the log originated from (usually the function name)
5761
* @param message the message of the log
5862
* @param apiKey the refreshToken
63+
* @param integrationUserId platypus user id
5964
* @param args additional data, will be stringified and appended
6065
*/
6166
export const warnLogger = (
6267
source: string,
6368
message: string,
6469
apiKey?: string,
70+
integrationUserId?: string,
6571
...args: unknown[]
6672
): void => {
67-
addMessageToTraceSpan('warn', message, args);
73+
addMessageToTraceSpan('warn', message, [...args, integrationUserId]);
6874

69-
logger(console.warn, source, message, apiKey, ...args);
75+
logger(console.warn, source, message, apiKey, integrationUserId, ...args);
7076
};
7177

7278
const logger = (
7379
logFn: (message?: any, ...optionalParams: any[]) => void,
7480
source: string,
7581
message: string,
7682
apiKey: string | undefined,
83+
integrationUserId: string | undefined,
7784
...args: unknown[]
7885
): void => {
7986
// eslint-disable-next-line no-console
8087
const anonymizedApiKey = apiKey ? anonymizeKey(apiKey) : undefined;
8188

8289
const formatedMessage = constructLogMessage(
8390
anonymizedApiKey ? `[${anonymizedApiKey}]` : undefined,
91+
integrationUserId ? `[${integrationUserId}]` : undefined,
8492
`[${source}]`,
8593
message,
8694
);
@@ -91,7 +99,7 @@ const logger = (
9199
logFn(
92100
JSON.stringify({
93101
message: formatedMessage,
94-
data: args,
102+
data: { ...args, integrationUserId },
95103
}),
96104
);
97105
}

0 commit comments

Comments
 (0)