@pvh-afl/core 1.2.62 → 1.2.63-uat.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/common/logger.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type LogLevel = 'info' | 'warn' | 'error';
|
|
2
|
+
/**
|
|
3
|
+
* A destination for log entries, in addition to stdout.
|
|
4
|
+
*
|
|
5
|
+
* Brands register one to forward logs somewhere else — Application Insights,
|
|
6
|
+
* for instance. Kept as a callback so core never depends on any vendor SDK.
|
|
7
|
+
*/
|
|
8
|
+
export type LogSink = (level: LogLevel, message: string, meta?: Record<string, unknown>) => void;
|
|
9
|
+
export declare function addLogSink(sink: LogSink): void;
|
|
10
|
+
export declare function log(level: LogLevel, message: string, meta?: Record<string, unknown>): void;
|
|
2
11
|
export declare const logger: {
|
|
3
12
|
info: (message: string, meta?: Record<string, unknown>) => void;
|
|
4
13
|
warn: (message: string, meta?: Record<string, unknown>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAIjG,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE9C;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QA2BnF;AAED,eAAO,MAAM,MAAM;oBACD,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBACtC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;qBACrC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CACxD,CAAC"}
|
package/dist/common/logger.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logger = void 0;
|
|
4
|
+
exports.addLogSink = addLogSink;
|
|
4
5
|
exports.log = log;
|
|
6
|
+
const sinks = [];
|
|
7
|
+
function addLogSink(sink) {
|
|
8
|
+
sinks.push(sink);
|
|
9
|
+
}
|
|
5
10
|
function log(level, message, meta) {
|
|
6
11
|
const entry = {
|
|
7
12
|
timestamp: new Date().toISOString(),
|
|
@@ -19,6 +24,16 @@ function log(level, message, meta) {
|
|
|
19
24
|
else {
|
|
20
25
|
console.log(output);
|
|
21
26
|
}
|
|
27
|
+
for (const sink of sinks) {
|
|
28
|
+
// A broken sink must never take down the caller, and must never recurse
|
|
29
|
+
// back into log() — so the failure goes straight to stderr.
|
|
30
|
+
try {
|
|
31
|
+
sink(level, message, meta);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
console.error(`log sink failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
22
37
|
}
|
|
23
38
|
exports.logger = {
|
|
24
39
|
info: (message, meta) => log('info', message, meta),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":";;;AAYA,gCAEC;AAED,kBA2BC;AAjCD,MAAM,K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