Skip to content

Commit 65759e9

Browse files
committed
♻️ change source styling to camelCase, add function documentation
1 parent 897b8bb commit 65759e9

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

src/util/logger.util.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { anonymizeKey } from "./anonymize-key";
22

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+
*/
310
export const infoLogger = (
411
source: string,
512
message: string,
@@ -11,18 +18,23 @@ export const infoLogger = (
1118
console.log(
1219
constructLogMessage(
1320
`[${anonymizeKey(apiKey)}]`,
14-
`[${source.toUpperCase()}]`,
21+
`[${source}]`,
1522
message,
1623
args
1724
)
1825
);
1926
} else {
20-
console.log(
21-
constructLogMessage(`[${source.toUpperCase()}]`, message, args)
22-
);
27+
console.log(constructLogMessage(`[${source}]`, message, args));
2328
}
2429
};
2530

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+
*/
2638
export const errorLogger = (
2739
source: string,
2840
message: string,
@@ -34,18 +46,23 @@ export const errorLogger = (
3446
console.error(
3547
constructLogMessage(
3648
`[${anonymizeKey(apiKey)}]`,
37-
`[${source.toUpperCase()}]`,
49+
`[${source}]`,
3850
message,
3951
args
4052
)
4153
);
4254
} else {
43-
console.error(
44-
constructLogMessage(`[${source.toUpperCase()}]`, message, args)
45-
);
55+
console.error(constructLogMessage(`[${source}]`, message, args));
4656
}
4757
};
4858

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+
*/
4966
export const warnLogger = (
5067
source: string,
5168
message: string,
@@ -57,15 +74,13 @@ export const warnLogger = (
5774
console.warn(
5875
constructLogMessage(
5976
`[${anonymizeKey(apiKey)}]`,
60-
`[${source.toUpperCase()}]`,
77+
`[${source}]`,
6178
message,
6279
args
6380
)
6481
);
6582
} else {
66-
console.warn(
67-
constructLogMessage(`[${source.toUpperCase()}]`, message, args)
68-
);
83+
console.warn(constructLogMessage(`[${source}]`, message, args));
6984
}
7085
};
7186

0 commit comments

Comments
 (0)