logixia 2.0.10 → 2.1.0
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/README.md +2 -1
- package/dist/{async-context-Dv0bmPC-.js → async-context-Dgl3ZLyb.js} +4 -4
- package/dist/{async-context-Dv0bmPC-.js.map → async-context-Dgl3ZLyb.js.map} +1 -1
- package/dist/{async-context-COuvmwsS.mjs → async-context-fBqC5lNc.mjs} +3 -3
- package/dist/{async-context-COuvmwsS.mjs.map → async-context-fBqC5lNc.mjs.map} +1 -1
- package/dist/{azure-monitor.transport-CbSHOnNX.d.mts → azure-monitor.transport-C5VjvREZ.d.mts} +2 -2
- package/dist/{azure-monitor.transport-CbSHOnNX.d.mts.map → azure-monitor.transport-C5VjvREZ.d.mts.map} +1 -1
- package/dist/{azure-monitor.transport-Bvf7Xegt.d.ts → azure-monitor.transport-CyHDjHS-.d.ts} +2 -2
- package/dist/{azure-monitor.transport-Bvf7Xegt.d.ts.map → azure-monitor.transport-CyHDjHS-.d.ts.map} +1 -1
- package/dist/{azure-monitor.transport-Coz5Gesu.mjs → azure-monitor.transport-DGiacfvT.mjs} +19 -8
- package/dist/{azure-monitor.transport-Coz5Gesu.mjs.map → azure-monitor.transport-DGiacfvT.mjs.map} +1 -1
- package/dist/{azure-monitor.transport-D6ryi8rA.js → azure-monitor.transport-DX3fuK2t.js} +19 -8
- package/dist/{azure-monitor.transport-D6ryi8rA.js.map → azure-monitor.transport-DX3fuK2t.js.map} +1 -1
- package/dist/azure.d.mts +1 -1
- package/dist/azure.d.ts +1 -1
- package/dist/azure.js +1 -1
- package/dist/azure.mjs +1 -1
- package/dist/{batch-buffer-CFzKnuNZ.js → batch-buffer-BLmVvJAZ.js} +11 -7
- package/dist/{batch-buffer-CFzKnuNZ.js.map → batch-buffer-BLmVvJAZ.js.map} +1 -1
- package/dist/{batch-buffer-CQUWDMYq.mjs → batch-buffer-CM-lK_Qy.mjs} +11 -7
- package/dist/{batch-buffer-CQUWDMYq.mjs.map → batch-buffer-CM-lK_Qy.mjs.map} +1 -1
- package/dist/browser.d.mts +2 -0
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +42 -13
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +42 -13
- package/dist/browser.mjs.map +1 -1
- package/dist/{builder-Bj3mDeBw.mjs → builder-CA_dokb4.mjs} +246 -101
- package/dist/builder-CA_dokb4.mjs.map +1 -0
- package/dist/{builder-BLIStsCK.js → builder-jMlVYaQa.js} +256 -111
- package/dist/builder-jMlVYaQa.js.map +1 -0
- package/dist/cli/index.js +21 -16
- package/dist/cloudwatch.d.mts +1 -1
- package/dist/cloudwatch.d.ts +1 -1
- package/dist/cloudwatch.js +1 -1
- package/dist/cloudwatch.mjs +1 -1
- package/dist/{cloudwatch.transport-Cr1aeTGj.mjs → cloudwatch.transport-Cr0fEpko.mjs} +24 -9
- package/dist/{cloudwatch.transport-Cr1aeTGj.mjs.map → cloudwatch.transport-Cr0fEpko.mjs.map} +1 -1
- package/dist/{cloudwatch.transport-CQyT6U91.d.ts → cloudwatch.transport-DdSjUWvu.d.ts} +2 -2
- package/dist/{cloudwatch.transport-CQyT6U91.d.ts.map → cloudwatch.transport-DdSjUWvu.d.ts.map} +1 -1
- package/dist/{cloudwatch.transport-D4G5xYfG.js → cloudwatch.transport-Lst1Bbmr.js} +24 -9
- package/dist/{cloudwatch.transport-D4G5xYfG.js.map → cloudwatch.transport-Lst1Bbmr.js.map} +1 -1
- package/dist/{cloudwatch.transport-CjVrI6S4.d.mts → cloudwatch.transport-_hS7Mcc5.d.mts} +2 -2
- package/dist/{cloudwatch.transport-CjVrI6S4.d.mts.map → cloudwatch.transport-_hS7Mcc5.d.mts.map} +1 -1
- package/dist/correlation.js +3 -3
- package/dist/correlation.mjs +3 -3
- package/dist/{coerce.utils-C1C5sIX0.js → csv.utils-CbVHY1pd.js} +24 -1
- package/dist/csv.utils-CbVHY1pd.js.map +1 -0
- package/dist/{coerce.utils-B_rEudCn.mjs → csv.utils-ZdxSod5g.mjs} +19 -2
- package/dist/csv.utils-ZdxSod5g.mjs.map +1 -0
- package/dist/{entry-fields-CVwoQplO.js → entry-fields-BSLkzw18.js} +3 -3
- package/dist/{entry-fields-CVwoQplO.js.map → entry-fields-BSLkzw18.js.map} +1 -1
- package/dist/{entry-fields-DNTKQxoU.mjs → entry-fields-J1OBi24o.mjs} +2 -2
- package/dist/{entry-fields-DNTKQxoU.mjs.map → entry-fields-J1OBi24o.mjs.map} +1 -1
- package/dist/gcp.d.mts +1 -1
- package/dist/gcp.d.ts +1 -1
- package/dist/gcp.js +1 -1
- package/dist/gcp.mjs +1 -1
- package/dist/{gcp.transport-CVuRpchl.js → gcp.transport-5-ZIjN8r.js} +18 -9
- package/dist/{gcp.transport-CVuRpchl.js.map → gcp.transport-5-ZIjN8r.js.map} +1 -1
- package/dist/{gcp.transport-D9SdLPwP.d.mts → gcp.transport-C8VJiEM7.d.mts} +2 -2
- package/dist/{gcp.transport-D9SdLPwP.d.mts.map → gcp.transport-C8VJiEM7.d.mts.map} +1 -1
- package/dist/{gcp.transport-BCIvdFV-.d.ts → gcp.transport-Ct0BtKFo.d.ts} +2 -2
- package/dist/{gcp.transport-BCIvdFV-.d.ts.map → gcp.transport-Ct0BtKFo.d.ts.map} +1 -1
- package/dist/{gcp.transport-LLK2bw2-.mjs → gcp.transport-Cw3Qke85.mjs} +18 -9
- package/dist/{gcp.transport-LLK2bw2-.mjs.map → gcp.transport-Cw3Qke85.mjs.map} +1 -1
- package/dist/{index-BAkPHp5D.d.mts → index-B3ajtXJd.d.mts} +2 -2
- package/dist/{index-BAkPHp5D.d.mts.map → index-B3ajtXJd.d.mts.map} +1 -1
- package/dist/{index-e7LowmAu.d.ts → index-oqD3WNxf.d.ts} +2 -2
- package/dist/{index-e7LowmAu.d.ts.map → index-oqD3WNxf.d.ts.map} +1 -1
- package/dist/index.d.mts +8 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{logitron-logger-DVUdgmBY.d.ts → logitron-logger-Csn3e6Qu.d.ts} +2 -2
- package/dist/{logitron-logger-DVUdgmBY.d.ts.map → logitron-logger-Csn3e6Qu.d.ts.map} +1 -1
- package/dist/{logitron-logger-DoWmMjYB.d.mts → logitron-logger-fMOkXr8H.d.mts} +2 -2
- package/dist/{logitron-logger-DoWmMjYB.d.mts.map → logitron-logger-fMOkXr8H.d.mts.map} +1 -1
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +12 -7
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +11 -6
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +51 -18
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +51 -18
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +207 -65
- package/dist/nest.js.map +1 -1
- package/dist/nest.mjs +202 -60
- package/dist/nest.mjs.map +1 -1
- package/dist/{otel-ChnVYRLA.js → otel-8ypFGG19.js} +452 -120
- package/dist/otel-8ypFGG19.js.map +1 -0
- package/dist/{otel-DOuwGPCd.mjs → otel-b-s2QbY4.mjs} +450 -118
- package/dist/otel-b-s2QbY4.mjs.map +1 -0
- package/dist/own-property-BWkibepN.js +40 -0
- package/dist/own-property-BWkibepN.js.map +1 -0
- package/dist/own-property-CjFw9qwZ.mjs +29 -0
- package/dist/own-property-CjFw9qwZ.mjs.map +1 -0
- package/dist/{request-trace-ByujsUZk.js → request-trace-C7kXMjx5.js} +5 -6
- package/dist/{request-trace-ByujsUZk.js.map → request-trace-C7kXMjx5.js.map} +1 -1
- package/dist/{request-trace-BgNykH9M.mjs → request-trace-Dekcnenb.mjs} +5 -6
- package/dist/{request-trace-BgNykH9M.mjs.map → request-trace-Dekcnenb.mjs.map} +1 -1
- package/dist/{safe-stringify--7gbe95n.mjs → safe-stringify-B5p5ktFe.mjs} +2 -2
- package/dist/{safe-stringify--7gbe95n.mjs.map → safe-stringify-B5p5ktFe.mjs.map} +1 -1
- package/dist/{safe-stringify-CN7icp8S.js → safe-stringify-J3sh-7YM.js} +5 -5
- package/dist/{safe-stringify-CN7icp8S.js.map → safe-stringify-J3sh-7YM.js.map} +1 -1
- package/dist/{search-DPwTKPve.d.ts → search-B-hJe2N-.d.mts} +9 -8
- package/dist/{search-D-8HJADE.d.mts.map → search-B-hJe2N-.d.mts.map} +1 -1
- package/dist/{search-D-8HJADE.d.mts → search-BlKBLm5D.d.ts} +9 -8
- package/dist/{search-DPwTKPve.d.ts.map → search-BlKBLm5D.d.ts.map} +1 -1
- package/dist/{search-DAXKE-P9.mjs → search-CTR4XNHq.mjs} +91 -44
- package/dist/search-CTR4XNHq.mjs.map +1 -0
- package/dist/{search-CRjhHxe9.js → search-_qx4YzRP.js} +94 -47
- package/dist/search-_qx4YzRP.js.map +1 -0
- package/dist/search.d.mts +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/search.js +1 -1
- package/dist/search.mjs +1 -1
- package/dist/{secret-config-BvFl2dC8.js → secret-config--cVTOWwp.js} +6 -5
- package/dist/{secret-config-BvFl2dC8.js.map → secret-config--cVTOWwp.js.map} +1 -1
- package/dist/{secret-config-ByGq7kJd.mjs → secret-config-GKmb15Me.mjs} +3 -2
- package/dist/{secret-config-ByGq7kJd.mjs.map → secret-config-GKmb15Me.mjs.map} +1 -1
- package/dist/{sensitive-names-o__1PUUR.mjs → sensitive-names-BiBM6R1X.mjs} +2 -28
- package/dist/sensitive-names-BiBM6R1X.mjs.map +1 -0
- package/dist/{sensitive-names-CHMowujD.js → sensitive-names-NiKIRhp5.js} +5 -37
- package/dist/sensitive-names-NiKIRhp5.js.map +1 -0
- package/dist/{slack.transport-BDyENuR0.d.mts → slack.transport-5OPL7H3u.d.mts} +76 -3
- package/dist/slack.transport-5OPL7H3u.d.mts.map +1 -0
- package/dist/{slack.transport-C6E0l4kw.d.ts → slack.transport-BFpBD_Ri.d.ts} +76 -3
- package/dist/slack.transport-BFpBD_Ri.d.ts.map +1 -0
- package/dist/{slack.transport-zLQ9MGxS.js → slack.transport-Cpx5fKga.js} +272 -21
- package/dist/slack.transport-Cpx5fKga.js.map +1 -0
- package/dist/{slack.transport-CSj1j0_X.mjs → slack.transport-Qwj9WkrJ.mjs} +267 -22
- package/dist/slack.transport-Qwj9WkrJ.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{transport.types-CzJq4IrF.d.ts → transport.types-B1ejJJP6.d.mts} +6 -1
- package/dist/transport.types-B1ejJJP6.d.mts.map +1 -0
- package/dist/{transport.types-CzJq4IrF.d.mts → transport.types-B1ejJJP6.d.ts} +6 -1
- package/dist/transport.types-B1ejJJP6.d.ts.map +1 -0
- package/dist/transports.d.mts +61 -11
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +61 -11
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +7 -6
- package/dist/transports.mjs +7 -7
- package/dist/worker-entry.js +200 -52
- package/dist/worker.d.mts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.mjs +1 -1
- package/dist/{worker.transport-B9mCQSM1.d.ts → worker.transport-B7olL1Uh.d.ts} +12 -2
- package/dist/worker.transport-B7olL1Uh.d.ts.map +1 -0
- package/dist/{worker.transport-D78xhNhB.mjs → worker.transport-BHnWDXPH.mjs} +59 -13
- package/dist/worker.transport-BHnWDXPH.mjs.map +1 -0
- package/dist/{worker.transport-DQDv1nAJ.js → worker.transport-C7jNGhev.js} +59 -13
- package/dist/worker.transport-C7jNGhev.js.map +1 -0
- package/dist/{worker.transport-Bl8lFRck.d.mts → worker.transport-DnU0_9Bd.d.mts} +12 -2
- package/dist/worker.transport-DnU0_9Bd.d.mts.map +1 -0
- package/package.json +10 -3
- package/dist/builder-BLIStsCK.js.map +0 -1
- package/dist/builder-Bj3mDeBw.mjs.map +0 -1
- package/dist/coerce.utils-B_rEudCn.mjs.map +0 -1
- package/dist/coerce.utils-C1C5sIX0.js.map +0 -1
- package/dist/otel-ChnVYRLA.js.map +0 -1
- package/dist/otel-DOuwGPCd.mjs.map +0 -1
- package/dist/search-CRjhHxe9.js.map +0 -1
- package/dist/search-DAXKE-P9.mjs.map +0 -1
- package/dist/sensitive-names-CHMowujD.js.map +0 -1
- package/dist/sensitive-names-o__1PUUR.mjs.map +0 -1
- package/dist/slack.transport-BDyENuR0.d.mts.map +0 -1
- package/dist/slack.transport-C6E0l4kw.d.ts.map +0 -1
- package/dist/slack.transport-CSj1j0_X.mjs.map +0 -1
- package/dist/slack.transport-zLQ9MGxS.js.map +0 -1
- package/dist/transport.types-CzJq4IrF.d.mts.map +0 -1
- package/dist/transport.types-CzJq4IrF.d.ts.map +0 -1
- package/dist/worker.transport-B9mCQSM1.d.ts.map +0 -1
- package/dist/worker.transport-Bl8lFRck.d.mts.map +0 -1
- package/dist/worker.transport-D78xhNhB.mjs.map +0 -1
- package/dist/worker.transport-DQDv1nAJ.js.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const require_secret_config = require("./secret-config
|
|
2
|
-
const
|
|
3
|
-
const require_request_trace = require("./request-trace-
|
|
4
|
-
const require_async_context = require("./async-context-
|
|
1
|
+
const require_secret_config = require("./secret-config--cVTOWwp.js");
|
|
2
|
+
const require_own_property = require("./own-property-BWkibepN.js");
|
|
3
|
+
const require_request_trace = require("./request-trace-C7kXMjx5.js");
|
|
4
|
+
const require_async_context = require("./async-context-Dgl3ZLyb.js");
|
|
5
|
+
const require_sensitive_names = require("./sensitive-names-NiKIRhp5.js");
|
|
5
6
|
const require_internal_log = require("./internal-log-DwqTjhpb.js");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const require_otel = require("./otel-
|
|
7
|
+
const require_safe_stringify = require("./safe-stringify-J3sh-7YM.js");
|
|
8
|
+
const require_csv_utils = require("./csv.utils-CbVHY1pd.js");
|
|
9
|
+
const require_otel = require("./otel-8ypFGG19.js");
|
|
9
10
|
let node_os = require("node:os");
|
|
10
11
|
// src/types/index.ts
|
|
11
12
|
const LogLevel = {
|
|
@@ -83,9 +84,7 @@ const DEFAULT_CONFIG = {
|
|
|
83
84
|
* singleton is also exported for process-wide registration.
|
|
84
85
|
*/
|
|
85
86
|
var PluginRegistry = class {
|
|
86
|
-
|
|
87
|
-
this._plugins = [];
|
|
88
|
-
}
|
|
87
|
+
_plugins = [];
|
|
89
88
|
/**
|
|
90
89
|
* Register a plugin. Silently skips if a plugin with the same `name` is
|
|
91
90
|
* already registered on this registry.
|
|
@@ -245,9 +244,9 @@ function _serializeError(error, includeStack, maxDepth, excludeFields, depth, se
|
|
|
245
244
|
for (const key of Object.getOwnPropertyNames(error)) {
|
|
246
245
|
if (skip.has(key)) continue;
|
|
247
246
|
try {
|
|
248
|
-
|
|
247
|
+
require_own_property.assignOwn(serialized, key, serializeValue(errorRecord[key], maxDepth - depth - 1, seen));
|
|
249
248
|
} catch {
|
|
250
|
-
|
|
249
|
+
require_own_property.assignOwn(serialized, key, "[Unserializable]");
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
252
|
return serialized;
|
|
@@ -283,9 +282,9 @@ function serializeValue(value, remainingDepth, seen) {
|
|
|
283
282
|
seen.add(value);
|
|
284
283
|
const out = {};
|
|
285
284
|
for (const [k, v] of Object.entries(value)) try {
|
|
286
|
-
|
|
285
|
+
require_own_property.assignOwn(out, k, serializeValue(v, remainingDepth - 1, seen));
|
|
287
286
|
} catch {
|
|
288
|
-
|
|
287
|
+
require_own_property.assignOwn(out, k, "[Unserializable]");
|
|
289
288
|
}
|
|
290
289
|
return out;
|
|
291
290
|
}
|
|
@@ -346,7 +345,7 @@ function walkForErrors(value, depth, parent, grandparent) {
|
|
|
346
345
|
const next = walkForErrors(item, depth - 1, record, parent);
|
|
347
346
|
if (next !== item) {
|
|
348
347
|
copy ??= { ...record };
|
|
349
|
-
|
|
348
|
+
require_own_property.assignOwn(copy, key, next);
|
|
350
349
|
}
|
|
351
350
|
}
|
|
352
351
|
}
|
|
@@ -517,6 +516,35 @@ const CIRCULAR = "[Circular]";
|
|
|
517
516
|
function joinPath(parent, key) {
|
|
518
517
|
return parent ? `${parent}.${key}` : key;
|
|
519
518
|
}
|
|
519
|
+
const CORRELATION_ID_KEYS = /* @__PURE__ */ new Set([
|
|
520
|
+
"traceid",
|
|
521
|
+
"spanid",
|
|
522
|
+
"parentspanid",
|
|
523
|
+
"requestid",
|
|
524
|
+
"correlationid",
|
|
525
|
+
"traceparent",
|
|
526
|
+
"xrequestid",
|
|
527
|
+
"xcorrelationid",
|
|
528
|
+
"xtraceid",
|
|
529
|
+
"xamzntraceid"
|
|
530
|
+
]);
|
|
531
|
+
const ID_SHAPED = /^[\w.:;=-]{1,256}$/;
|
|
532
|
+
const DEFAULT_QUERY_NAMES = require_sensitive_names.buildNameSet(require_sensitive_names.DEFAULT_REDACT_QUERY_PARAMS, void 0);
|
|
533
|
+
const queryNameSets = /* @__PURE__ */ new WeakMap();
|
|
534
|
+
function queryNamesOf(config) {
|
|
535
|
+
const extra = config.queryParams;
|
|
536
|
+
if (!extra || extra.length === 0) return DEFAULT_QUERY_NAMES;
|
|
537
|
+
let names = queryNameSets.get(extra);
|
|
538
|
+
if (!names) {
|
|
539
|
+
names = require_sensitive_names.buildNameSet(require_sensitive_names.DEFAULT_REDACT_QUERY_PARAMS, extra);
|
|
540
|
+
queryNameSets.set(extra, names);
|
|
541
|
+
}
|
|
542
|
+
return names;
|
|
543
|
+
}
|
|
544
|
+
function isCorrelationId(fullPath, value) {
|
|
545
|
+
const key = fullPath.slice(fullPath.lastIndexOf(".") + 1);
|
|
546
|
+
return CORRELATION_ID_KEYS.has(key.toLowerCase().replace(/[-_]/g, "")) && ID_SHAPED.test(value);
|
|
547
|
+
}
|
|
520
548
|
function walkValue(value, state, fullPath, bare, depth) {
|
|
521
549
|
const { paths = [], excludePaths = [], patterns = [], censor = DEFAULT_CENSOR } = state.config;
|
|
522
550
|
if (paths.some((p) => matchesPath(fullPath, p) || matchesPath(bare, p))) return censor;
|
|
@@ -526,8 +554,9 @@ function walkValue(value, state, fullPath, bare, depth) {
|
|
|
526
554
|
}
|
|
527
555
|
if (typeof value === "string") {
|
|
528
556
|
if (patterns.length === 0) return value;
|
|
557
|
+
if (isCorrelationId(fullPath, value)) return value;
|
|
529
558
|
if (excludePaths.some((p) => matchesPath(fullPath, p) || matchesPath(bare, p))) return value;
|
|
530
|
-
return applyPatterns(value, patterns, censor);
|
|
559
|
+
return applyPatterns(value.includes("?") ? require_sensitive_names.redactUrlsInText(value, queryNamesOf(state.config)) : value, patterns, censor);
|
|
531
560
|
}
|
|
532
561
|
if (Array.isArray(value)) return walkContainer(value, state, fullPath, bare, depth, walkArray);
|
|
533
562
|
if (value instanceof Error) return walkContainer(value, state, fullPath, bare, depth, walkError);
|
|
@@ -535,7 +564,7 @@ function walkValue(value, state, fullPath, bare, depth) {
|
|
|
535
564
|
const url = new URL(value.href);
|
|
536
565
|
url.username = "";
|
|
537
566
|
url.password = "";
|
|
538
|
-
const redacted = walkValue(url.href, state, fullPath, bare, depth);
|
|
567
|
+
const redacted = walkValue(require_sensitive_names.redactUrlQuery(url.href, queryNamesOf(state.config)), state, fullPath, bare, depth);
|
|
539
568
|
return redacted === value.href ? value : redacted;
|
|
540
569
|
}
|
|
541
570
|
if (isPlainObject(value)) return walkContainer(value, state, fullPath, bare, depth, typeof value.toJSON === "function" ? walkToJSON : walkRecord);
|
|
@@ -569,7 +598,7 @@ function walkRecord(obj, state, fullPath, bare, depth) {
|
|
|
569
598
|
for (const [index, [key, value]] of entries.entries()) {
|
|
570
599
|
const next = walkValue(value, state, joinPath(fullPath, key), joinPath(bare, key), depth);
|
|
571
600
|
if (next !== value && !result) result = Object.fromEntries(entries.slice(0, index));
|
|
572
|
-
if (result)
|
|
601
|
+
if (result) require_own_property.assignOwn(result, key, next);
|
|
573
602
|
}
|
|
574
603
|
return result ?? obj;
|
|
575
604
|
}
|
|
@@ -611,15 +640,28 @@ function redactObject(obj, config, _currentPath = "") {
|
|
|
611
640
|
}, _currentPath, _currentPath, 0);
|
|
612
641
|
return result === obj ? { ...obj } : result;
|
|
613
642
|
}
|
|
643
|
+
function redactMessageObject(value, config) {
|
|
644
|
+
if (!Array.isArray(value)) return applyRedaction(value, config);
|
|
645
|
+
return value.map((item) => {
|
|
646
|
+
var _applyRedaction;
|
|
647
|
+
if (typeof item === "string") return applyRedactionToString(item, config);
|
|
648
|
+
if (item === null || typeof item !== "object") return item;
|
|
649
|
+
if (!Array.isArray(item)) return applyRedaction(item, config);
|
|
650
|
+
return (_applyRedaction = applyRedaction({ items: item }, config)) === null || _applyRedaction === void 0 ? void 0 : _applyRedaction["items"];
|
|
651
|
+
});
|
|
652
|
+
}
|
|
614
653
|
/**
|
|
615
|
-
* Apply
|
|
654
|
+
* Apply redaction to the log message and return it as a string.
|
|
616
655
|
*
|
|
617
|
-
*
|
|
656
|
+
* A string message gets only the `patterns`, because path rules don't apply to a
|
|
657
|
+
* bare string. An object logged as the message (`logger.log(dto)` in NestJS) gets
|
|
658
|
+
* every rule, as a payload would, before it is turned into a string.
|
|
618
659
|
* Returns the input unchanged when no patterns are configured, so the hot path
|
|
619
660
|
* stays allocation-free for the common no-redact case.
|
|
620
661
|
*/
|
|
621
662
|
function applyRedactionToString(value, config) {
|
|
622
|
-
|
|
663
|
+
if (config && value !== null && typeof value === "object") return require_csv_utils.safeToString(redactMessageObject(value, config));
|
|
664
|
+
const text = typeof value === "string" ? value : require_csv_utils.safeToString(value);
|
|
623
665
|
if (!config) return text;
|
|
624
666
|
const resolved = resolveConfig(config);
|
|
625
667
|
if (!resolved.patterns || resolved.patterns.length === 0) return text;
|
|
@@ -670,25 +712,54 @@ function isCacheableTraceId(id) {
|
|
|
670
712
|
}
|
|
671
713
|
return true;
|
|
672
714
|
}
|
|
715
|
+
/** Maps a trace id to a stable number in [0, 1): FNV-1a followed by a murmur3 finalizer. */
|
|
716
|
+
function traceFraction(id) {
|
|
717
|
+
let h = 2166136261;
|
|
718
|
+
for (let i = 0; i < id.length; i++) {
|
|
719
|
+
h ^= id.charCodeAt(i);
|
|
720
|
+
h = Math.imul(h, 16777619);
|
|
721
|
+
}
|
|
722
|
+
h ^= h >>> 16;
|
|
723
|
+
h = Math.imul(h, 2246822507);
|
|
724
|
+
h ^= h >>> 13;
|
|
725
|
+
h = Math.imul(h, 3266489909);
|
|
726
|
+
h ^= h >>> 16;
|
|
727
|
+
return (h >>> 0) / 4294967296;
|
|
728
|
+
}
|
|
729
|
+
const ADAPTIVE_BUCKETS = 100;
|
|
673
730
|
var Sampler = class {
|
|
731
|
+
config;
|
|
732
|
+
/**
|
|
733
|
+
* Per-trace sampling fractions in LRU order (Map preserves insertion order; a
|
|
734
|
+
* hit re-inserts the key). A trace is kept at a level when its fraction is below
|
|
735
|
+
* that level's rate, so it is never fixed by the first level seen. Survives
|
|
736
|
+
* resetStats() so a long trace is not re-evaluated mid-flight. Bounded by size, by an idle TTL (refreshed on hit) and by a hard
|
|
737
|
+
* lifetime measured from the first decision.
|
|
738
|
+
*/
|
|
739
|
+
traceDecisions = /* @__PURE__ */ new Map();
|
|
740
|
+
maxTrackedTraces = 1e5;
|
|
741
|
+
traceTtlMs = 3e5;
|
|
742
|
+
traceMaxLifetimeMs = 36e5;
|
|
743
|
+
_tokenBucket = 0;
|
|
744
|
+
_lastRefillMs = Date.now();
|
|
745
|
+
_adaptiveBucketMs;
|
|
746
|
+
_adaptiveTotals = new Float64Array(ADAPTIVE_BUCKETS);
|
|
747
|
+
_adaptiveErrorCounts = new Float64Array(ADAPTIVE_BUCKETS);
|
|
748
|
+
_adaptiveBucket = 0;
|
|
749
|
+
_adaptiveTotal = 0;
|
|
750
|
+
_adaptiveErrors = 0;
|
|
751
|
+
_stats = {
|
|
752
|
+
evaluated: 0,
|
|
753
|
+
emitted: 0,
|
|
754
|
+
dropped: 0,
|
|
755
|
+
byLevel: {},
|
|
756
|
+
windowStart: Date.now()
|
|
757
|
+
};
|
|
758
|
+
_statsTimer;
|
|
674
759
|
constructor(config, onStats) {
|
|
675
|
-
|
|
676
|
-
this.maxTrackedTraces = 1e5;
|
|
677
|
-
this.traceTtlMs = 3e5;
|
|
678
|
-
this.traceMaxLifetimeMs = 36e5;
|
|
679
|
-
this._tokenBucket = 0;
|
|
680
|
-
this._lastRefillMs = Date.now();
|
|
681
|
-
this._adaptiveWindow = [];
|
|
682
|
-
this._adaptiveHead = 0;
|
|
683
|
-
this._adaptiveErrors = 0;
|
|
684
|
-
this._stats = {
|
|
685
|
-
evaluated: 0,
|
|
686
|
-
emitted: 0,
|
|
687
|
-
dropped: 0,
|
|
688
|
-
byLevel: {},
|
|
689
|
-
windowStart: Date.now()
|
|
690
|
-
};
|
|
760
|
+
var _config$adaptive;
|
|
691
761
|
this.config = config;
|
|
762
|
+
this._adaptiveBucketMs = Math.max(1, Math.ceil((((_config$adaptive = config.adaptive) === null || _config$adaptive === void 0 ? void 0 : _config$adaptive.windowMs) ?? 1e4) / ADAPTIVE_BUCKETS));
|
|
692
763
|
if (config.maxLogsPerSecond && config.maxLogsPerSecond > 0) this._tokenBucket = config.maxLogsPerSecond;
|
|
693
764
|
const interval = config.statsIntervalMs ?? 6e4;
|
|
694
765
|
if (interval > 0 && onStats) {
|
|
@@ -746,34 +817,38 @@ var Sampler = class {
|
|
|
746
817
|
destroy() {
|
|
747
818
|
if (this._statsTimer) clearInterval(this._statsTimer);
|
|
748
819
|
}
|
|
749
|
-
_sampleByRate(level) {
|
|
820
|
+
_sampleByRate(level, fraction) {
|
|
750
821
|
var _this$config$perLevel2, _this$config$perLevel3;
|
|
751
822
|
const baseRate = ((_this$config$perLevel2 = this.config.perLevel) === null || _this$config$perLevel2 === void 0 ? void 0 : _this$config$perLevel2[level]) ?? ((_this$config$perLevel3 = this.config.perLevel) === null || _this$config$perLevel3 === void 0 ? void 0 : _this$config$perLevel3["*"]) ?? this.config.rate ?? 1;
|
|
752
823
|
const rate = Math.max(baseRate, this._adaptiveBoostRate());
|
|
753
824
|
if (rate >= 1) return true;
|
|
754
825
|
if (rate <= 0) return false;
|
|
826
|
+
if (fraction !== void 0) return fraction < rate;
|
|
755
827
|
return Math.random() < rate;
|
|
756
828
|
}
|
|
757
|
-
/**
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
const cutoff = now - windowMs;
|
|
769
|
-
const win = this._adaptiveWindow;
|
|
770
|
-
while (this._adaptiveHead < win.length && win[this._adaptiveHead].t < cutoff) {
|
|
771
|
-
if (win[this._adaptiveHead].err) this._adaptiveErrors -= 1;
|
|
772
|
-
this._adaptiveHead += 1;
|
|
829
|
+
/** Moves the ring forward to the bucket holding `now`, dropping buckets that left the window. */
|
|
830
|
+
_advanceAdaptive(now) {
|
|
831
|
+
const target = Math.floor(now / this._adaptiveBucketMs);
|
|
832
|
+
if (target <= this._adaptiveBucket) return this._adaptiveBucket;
|
|
833
|
+
const steps = Math.min(target - this._adaptiveBucket, ADAPTIVE_BUCKETS);
|
|
834
|
+
for (let i = 1; i <= steps; i++) {
|
|
835
|
+
const slot = (this._adaptiveBucket + i) % ADAPTIVE_BUCKETS;
|
|
836
|
+
this._adaptiveTotal -= this._adaptiveTotals[slot];
|
|
837
|
+
this._adaptiveErrors -= this._adaptiveErrorCounts[slot];
|
|
838
|
+
this._adaptiveTotals[slot] = 0;
|
|
839
|
+
this._adaptiveErrorCounts[slot] = 0;
|
|
773
840
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
841
|
+
this._adaptiveBucket = target;
|
|
842
|
+
return target;
|
|
843
|
+
}
|
|
844
|
+
/** Record one evaluated sample in the current bucket. O(1). */
|
|
845
|
+
_recordAdaptiveSample(level) {
|
|
846
|
+
const slot = this._advanceAdaptive(Date.now()) % ADAPTIVE_BUCKETS;
|
|
847
|
+
this._adaptiveTotals[slot] += 1;
|
|
848
|
+
this._adaptiveTotal += 1;
|
|
849
|
+
if (level === "error" || level === "fatal") {
|
|
850
|
+
this._adaptiveErrorCounts[slot] += 1;
|
|
851
|
+
this._adaptiveErrors += 1;
|
|
777
852
|
}
|
|
778
853
|
}
|
|
779
854
|
/**
|
|
@@ -784,8 +859,9 @@ var Sampler = class {
|
|
|
784
859
|
_adaptiveBoostRate() {
|
|
785
860
|
const cfg = this.config.adaptive;
|
|
786
861
|
if (!cfg) return 0;
|
|
862
|
+
this._advanceAdaptive(Date.now());
|
|
787
863
|
const minSamples = cfg.minSamples ?? 20;
|
|
788
|
-
const total = this.
|
|
864
|
+
const total = this._adaptiveTotal;
|
|
789
865
|
if (total < minSamples) return 0;
|
|
790
866
|
return this._adaptiveErrors / total >= (cfg.errorRateThreshold ?? .05) ? cfg.boostRate ?? 1 : 0;
|
|
791
867
|
}
|
|
@@ -794,8 +870,9 @@ var Sampler = class {
|
|
|
794
870
|
return this._adaptiveBoostRate() > 0;
|
|
795
871
|
}
|
|
796
872
|
/**
|
|
797
|
-
*
|
|
798
|
-
* idle past the TTL, or older than the hard lifetime, are
|
|
873
|
+
* Decide a trace by comparing its stable fraction with the level's rate, caching
|
|
874
|
+
* the fraction. Entries idle past the TTL, or older than the hard lifetime, are
|
|
875
|
+
* recomputed; the least
|
|
799
876
|
* recently used entry is evicted once the cap is reached. IDs that are empty,
|
|
800
877
|
* too long or contain control characters are sampled independently and never cached.
|
|
801
878
|
*/
|
|
@@ -807,12 +884,12 @@ var Sampler = class {
|
|
|
807
884
|
this.traceDecisions.delete(traceId);
|
|
808
885
|
known.seenAt = now;
|
|
809
886
|
this.traceDecisions.set(traceId, known);
|
|
810
|
-
return known.
|
|
887
|
+
return this._sampleByRate(level, known.fraction);
|
|
811
888
|
}
|
|
812
|
-
const
|
|
889
|
+
const fraction = traceFraction(traceId);
|
|
813
890
|
this.traceDecisions.delete(traceId);
|
|
814
891
|
this.traceDecisions.set(traceId, {
|
|
815
|
-
|
|
892
|
+
fraction,
|
|
816
893
|
firstAt: now,
|
|
817
894
|
seenAt: now
|
|
818
895
|
});
|
|
@@ -820,7 +897,7 @@ var Sampler = class {
|
|
|
820
897
|
const oldest = this.traceDecisions.keys().next().value;
|
|
821
898
|
if (oldest !== void 0) this.traceDecisions.delete(oldest);
|
|
822
899
|
}
|
|
823
|
-
return
|
|
900
|
+
return this._sampleByRate(level, fraction);
|
|
824
901
|
}
|
|
825
902
|
_consumeToken() {
|
|
826
903
|
const now = Date.now();
|
|
@@ -897,7 +974,8 @@ function deregisterFromShutdown(logger) {
|
|
|
897
974
|
* the process exits. Idempotent — the first call wins and later calls with
|
|
898
975
|
* conflicting options print a warning. The process is ended with 128 + signal
|
|
899
976
|
* number only when logixia's handler is the sole listener for that signal (see
|
|
900
|
-
* `exit`); otherwise it
|
|
977
|
+
* `exit`), closing the loggers first; otherwise it only flushes them and leaves
|
|
978
|
+
* shutdown to the application.
|
|
901
979
|
* Loggers are also flushed (not closed) on `beforeExit`.
|
|
902
980
|
*
|
|
903
981
|
* @example
|
|
@@ -924,7 +1002,8 @@ function flushOnExit(options = {}) {
|
|
|
924
1002
|
}, timeout).unref() : void 0;
|
|
925
1003
|
try {
|
|
926
1004
|
if (beforeFlush) await beforeFlush();
|
|
927
|
-
|
|
1005
|
+
const ownsExit = shouldExit(signal);
|
|
1006
|
+
await Promise.allSettled([...registry].map((logger) => ownsExit || !logger.flush ? logger.close() : logger.flush()));
|
|
928
1007
|
if (afterFlush) await afterFlush();
|
|
929
1008
|
} catch (err) {
|
|
930
1009
|
process.stderr.write(`[logixia] Shutdown hook failed: ${String(err)}\n`);
|
|
@@ -1045,6 +1124,7 @@ function nowIso() {
|
|
|
1045
1124
|
return _tsCacheStr;
|
|
1046
1125
|
}
|
|
1047
1126
|
const RESOLVED = Promise.resolve();
|
|
1127
|
+
const UNSERIALIZABLE = "[Unserializable]";
|
|
1048
1128
|
const JSON_STRING_FIELDS = [
|
|
1049
1129
|
"timestamp",
|
|
1050
1130
|
"level",
|
|
@@ -1079,7 +1159,22 @@ function toJsonEntry(entry) {
|
|
|
1079
1159
|
}
|
|
1080
1160
|
function toContextLabel(context) {
|
|
1081
1161
|
if (context === void 0 || context === null) return "";
|
|
1082
|
-
return typeof context === "string" ? context :
|
|
1162
|
+
return typeof context === "string" ? context : require_csv_utils.safeToString(context);
|
|
1163
|
+
}
|
|
1164
|
+
function serializeErrorSafely(error) {
|
|
1165
|
+
try {
|
|
1166
|
+
return serializeError(error);
|
|
1167
|
+
} catch (cause) {
|
|
1168
|
+
require_internal_log.internalError("Error serialization failed", cause);
|
|
1169
|
+
return UNSERIALIZABLE;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function errorMessageSafely(error) {
|
|
1173
|
+
try {
|
|
1174
|
+
return require_csv_utils.safeToString(error.message);
|
|
1175
|
+
} catch {
|
|
1176
|
+
return UNSERIALIZABLE;
|
|
1177
|
+
}
|
|
1083
1178
|
}
|
|
1084
1179
|
function namespacePatternToRegex(pattern) {
|
|
1085
1180
|
const escaped = pattern.split(".").map((s) => s === "*" ? "[^.]+" : s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("\\.");
|
|
@@ -1149,26 +1244,58 @@ function resolveInitialLevel(config) {
|
|
|
1149
1244
|
* ```
|
|
1150
1245
|
*/
|
|
1151
1246
|
var LogixiaLogger = class LogixiaLogger {
|
|
1247
|
+
config;
|
|
1248
|
+
context;
|
|
1249
|
+
timers = /* @__PURE__ */ new Map();
|
|
1250
|
+
contextData = {};
|
|
1251
|
+
transportManager;
|
|
1252
|
+
fieldState = /* @__PURE__ */ new Map();
|
|
1253
|
+
/** Stable fallback trace ID generated ONCE per logger instance. */
|
|
1254
|
+
fallbackTraceId = require_request_trace.TraceContext.instance.generate();
|
|
1255
|
+
/** Numeric value for each known log level — built once, read on every log call. */
|
|
1256
|
+
_levelValues = /* @__PURE__ */ new Map();
|
|
1257
|
+
/** Numeric threshold for the currently active log level. */
|
|
1258
|
+
_minLevelValue = 2;
|
|
1259
|
+
/** Level set via setLevel(); outranks every other level source until the process ends. */
|
|
1260
|
+
_runtimeLevel;
|
|
1261
|
+
/** `source=value` pairs already reported as unknown levels — warn once per logger. */
|
|
1262
|
+
_warnedInvalidLevels = /* @__PURE__ */ new Set();
|
|
1263
|
+
/** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
|
|
1264
|
+
_colorMap = /* @__PURE__ */ new Map();
|
|
1265
|
+
/** Pre-computed field-enabled booleans so isFieldEnabled() isn't called per log. */
|
|
1266
|
+
_fieldCache = /* @__PURE__ */ new Map();
|
|
1267
|
+
/** True when contextData is non-empty — avoids Object.keys() check on hot path. */
|
|
1268
|
+
_hasContextData = false;
|
|
1269
|
+
/**
|
|
1270
|
+
* Pre-computed `[INFO] `, `[WARN] ` etc. strings — avoids a colorize() call per log.
|
|
1271
|
+
* Key: lowercase level name. Value: formatted bracket string ready to concatenate.
|
|
1272
|
+
*/
|
|
1273
|
+
_formattedLevels = /* @__PURE__ */ new Map();
|
|
1274
|
+
/** Pre-computed `[appName] ` string — avoids template literal allocation per log. */
|
|
1275
|
+
_formattedAppName = "";
|
|
1276
|
+
/**
|
|
1277
|
+
* JSON line pieces between the timestamp and the message, keyed by level, for the
|
|
1278
|
+
* appName and environment they were built from. Rebuilt when either changes.
|
|
1279
|
+
*/
|
|
1280
|
+
_jsonHeads = /* @__PURE__ */ new Map();
|
|
1281
|
+
_jsonHeadsApp = "";
|
|
1282
|
+
_jsonHeadsEnv = "";
|
|
1283
|
+
/** The `,"context":"..."` piece for `_jsonContextKey`. */
|
|
1284
|
+
_jsonContextKey = void 0;
|
|
1285
|
+
_jsonContext = "";
|
|
1286
|
+
/** True when a redact config is present — short-circuits applyRedaction when false. */
|
|
1287
|
+
_hasRedact = false;
|
|
1288
|
+
/** Sampling engine — only created when sampling config is present. */
|
|
1289
|
+
_sampler;
|
|
1290
|
+
/** Per-instance plugin registry — also inherits from the global registry at creation time. */
|
|
1291
|
+
_pluginRegistry;
|
|
1292
|
+
/** Set on loggers created by child(); they borrow the root's transports, sampler and plugins. */
|
|
1293
|
+
_parent;
|
|
1294
|
+
/** Namespace level map shared by a logger and all its children; `version` bumps on every change. */
|
|
1295
|
+
_nsStore;
|
|
1296
|
+
/** Store version this logger's threshold was last computed against. */
|
|
1297
|
+
_nsSeenVersion = 0;
|
|
1152
1298
|
constructor(config, context, parent) {
|
|
1153
|
-
this.timers = /* @__PURE__ */ new Map();
|
|
1154
|
-
this.contextData = {};
|
|
1155
|
-
this.fieldState = /* @__PURE__ */ new Map();
|
|
1156
|
-
this.fallbackTraceId = require_request_trace.TraceContext.instance.generate();
|
|
1157
|
-
this._levelValues = /* @__PURE__ */ new Map();
|
|
1158
|
-
this._minLevelValue = 2;
|
|
1159
|
-
this._warnedInvalidLevels = /* @__PURE__ */ new Set();
|
|
1160
|
-
this._colorMap = /* @__PURE__ */ new Map();
|
|
1161
|
-
this._fieldCache = /* @__PURE__ */ new Map();
|
|
1162
|
-
this._hasContextData = false;
|
|
1163
|
-
this._formattedLevels = /* @__PURE__ */ new Map();
|
|
1164
|
-
this._formattedAppName = "";
|
|
1165
|
-
this._jsonHeads = /* @__PURE__ */ new Map();
|
|
1166
|
-
this._jsonHeadsApp = "";
|
|
1167
|
-
this._jsonHeadsEnv = "";
|
|
1168
|
-
this._jsonContextKey = void 0;
|
|
1169
|
-
this._jsonContext = "";
|
|
1170
|
-
this._hasRedact = false;
|
|
1171
|
-
this._nsSeenVersion = 0;
|
|
1172
1299
|
this._parent = parent;
|
|
1173
1300
|
this._nsStore = parent ? parent._nsStore : {
|
|
1174
1301
|
levels: { ...config.namespaceLevels },
|
|
@@ -1264,19 +1391,25 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1264
1391
|
});
|
|
1265
1392
|
}
|
|
1266
1393
|
createCustomLevelMethods() {
|
|
1267
|
-
var _this$config$levelOpt3
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1394
|
+
var _this$config$levelOpt3;
|
|
1395
|
+
const levels = (_this$config$levelOpt3 = this.config.levelOptions) === null || _this$config$levelOpt3 === void 0 ? void 0 : _this$config$levelOpt3.levels;
|
|
1396
|
+
warnOnReservedLevelNames(levels);
|
|
1397
|
+
if (!levels) return;
|
|
1398
|
+
const self = this;
|
|
1399
|
+
const names = Object.keys(levels);
|
|
1400
|
+
const define = (method, levelName) => {
|
|
1401
|
+
if (!self[method]) self[method] = (message, data) => this.logLevel(levelName, message, data);
|
|
1402
|
+
};
|
|
1403
|
+
for (const levelName of names) define(levelName, levelName);
|
|
1404
|
+
for (const levelName of names) define(levelName.toLowerCase(), levelName);
|
|
1272
1405
|
}
|
|
1273
1406
|
/**
|
|
1274
1407
|
* Rebuild all hot-path caches after any config mutation or level change.
|
|
1275
1408
|
* Keeps the actual log() call free of allocations in the common case.
|
|
1276
1409
|
*/
|
|
1277
1410
|
_buildPerfCaches() {
|
|
1278
|
-
var _this$config$
|
|
1279
|
-
const customLevelEntries = Object.entries(((_this$config$
|
|
1411
|
+
var _this$config$levelOpt4, _this$config$format, _this$config$redact$p, _this$config$redact$p2;
|
|
1412
|
+
const customLevelEntries = Object.entries(((_this$config$levelOpt4 = this.config.levelOptions) === null || _this$config$levelOpt4 === void 0 ? void 0 : _this$config$levelOpt4.levels) ?? {});
|
|
1280
1413
|
this._levelValues = new Map([
|
|
1281
1414
|
[LogLevel.ERROR, 0],
|
|
1282
1415
|
[LogLevel.WARN, 1],
|
|
@@ -1345,8 +1478,8 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1345
1478
|
for (const [lvl] of this._levelValues) {
|
|
1346
1479
|
const upper = lvl.toUpperCase();
|
|
1347
1480
|
if (colorize && this._fieldCache.get("level") !== false) {
|
|
1348
|
-
var _this$config$
|
|
1349
|
-
let colorName = (_this$config$
|
|
1481
|
+
var _this$config$levelOpt5;
|
|
1482
|
+
let colorName = (_this$config$levelOpt5 = this.config.levelOptions) === null || _this$config$levelOpt5 === void 0 || (_this$config$levelOpt5 = _this$config$levelOpt5.colors) === null || _this$config$levelOpt5 === void 0 ? void 0 : _this$config$levelOpt5[lvl];
|
|
1350
1483
|
if (!colorName) {
|
|
1351
1484
|
if (_BUILTIN_LEVELS.has(lvl)) colorName = "white";
|
|
1352
1485
|
else {
|
|
@@ -1371,9 +1504,9 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1371
1504
|
*/
|
|
1372
1505
|
error(messageOrError, data) {
|
|
1373
1506
|
try {
|
|
1374
|
-
return isError(messageOrError) ? this._run("error", messageOrError
|
|
1507
|
+
return isError(messageOrError) ? this._run("error", errorMessageSafely(messageOrError), {
|
|
1375
1508
|
...data,
|
|
1376
|
-
error:
|
|
1509
|
+
error: serializeErrorSafely(messageOrError)
|
|
1377
1510
|
}) : this._run("error", messageOrError, data);
|
|
1378
1511
|
} catch (error) {
|
|
1379
1512
|
return Promise.reject(error);
|
|
@@ -1493,8 +1626,8 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1493
1626
|
* else a `NODE_ENV` default (`debug` in development, `warn` in test), else `info`.
|
|
1494
1627
|
*/
|
|
1495
1628
|
getLevel() {
|
|
1496
|
-
var _this$config$
|
|
1497
|
-
return ((_this$config$
|
|
1629
|
+
var _this$config$levelOpt6;
|
|
1630
|
+
return ((_this$config$levelOpt6 = this.config.levelOptions) === null || _this$config$levelOpt6 === void 0 ? void 0 : _this$config$levelOpt6.level) ?? LogLevel.INFO;
|
|
1498
1631
|
}
|
|
1499
1632
|
_validLevelList() {
|
|
1500
1633
|
return [...this._levelValues.keys()].join(", ");
|
|
@@ -1557,7 +1690,8 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1557
1690
|
}
|
|
1558
1691
|
/** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
|
|
1559
1692
|
setContext(context) {
|
|
1560
|
-
this.context = typeof context === "string" ? context :
|
|
1693
|
+
this.context = typeof context === "string" ? context : require_csv_utils.safeToString(context);
|
|
1694
|
+
this._syncNamespaceLevels();
|
|
1561
1695
|
}
|
|
1562
1696
|
/** Return the current context label, or `undefined` if none is set. */
|
|
1563
1697
|
getContext() {
|
|
@@ -1726,7 +1860,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1726
1860
|
const config = this.config;
|
|
1727
1861
|
if (config.silent) return;
|
|
1728
1862
|
if (!this.shouldLog(level)) return;
|
|
1729
|
-
const data = rawData instanceof Error ? { error:
|
|
1863
|
+
const data = rawData instanceof Error ? { error: serializeErrorSafely(rawData) } : rawData;
|
|
1730
1864
|
const alsContext = require_async_context.LogixiaContext.get();
|
|
1731
1865
|
let activeTraceId;
|
|
1732
1866
|
if (config.traceId) {
|
|
@@ -1771,7 +1905,8 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1771
1905
|
}
|
|
1772
1906
|
else payload = rawPayload;
|
|
1773
1907
|
}
|
|
1774
|
-
|
|
1908
|
+
const rawMessage = message;
|
|
1909
|
+
let safeMessage = rawMessage !== null && typeof rawMessage === "object" ? require_csv_utils.safeToString(rawMessage) : message;
|
|
1775
1910
|
if (this._hasRedact) try {
|
|
1776
1911
|
safeMessage = applyRedactionToString(message, config.redact);
|
|
1777
1912
|
} catch (error) {
|
|
@@ -1861,7 +1996,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1861
1996
|
formatted += this._formattedAppName;
|
|
1862
1997
|
if (entry.traceId && this._fieldCache.get("traceId") !== false) formatted += `${cyan}[${require_otel.stripControlChars(String(entry.traceId))}]${reset} `;
|
|
1863
1998
|
if (entry.context && this._fieldCache.get("context") !== false) formatted += `${yellow}[${require_otel.stripControlChars(String(entry.context))}]${reset} `;
|
|
1864
|
-
if (this._fieldCache.get("message") !== false) formatted += require_otel.stripControlChars(
|
|
1999
|
+
if (this._fieldCache.get("message") !== false) formatted += require_otel.stripControlChars(require_csv_utils.safeToString(entry.message));
|
|
1865
2000
|
if (entry.payload !== void 0 && this._fieldCache.get("payload") !== false) formatted += ` ${require_safe_stringify.stringifyForLog(entry.payload)}`;
|
|
1866
2001
|
return formatted;
|
|
1867
2002
|
}
|
|
@@ -1952,16 +2087,26 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1952
2087
|
* ```
|
|
1953
2088
|
*/
|
|
1954
2089
|
function createLogger(config, context) {
|
|
1955
|
-
|
|
1956
|
-
const logger = new LogixiaLogger(config, context);
|
|
1957
|
-
const mutableLogger = logger;
|
|
1958
|
-
if ((_config$levelOptions3 = config.levelOptions) === null || _config$levelOptions3 === void 0 ? void 0 : _config$levelOptions3.levels) {
|
|
1959
|
-
for (const levelName of Object.keys(config.levelOptions.levels)) if (!mutableLogger[levelName]) mutableLogger[levelName] = (message, data) => logger.logLevel(levelName, message, data);
|
|
1960
|
-
}
|
|
1961
|
-
return logger;
|
|
2090
|
+
return new LogixiaLogger(config, context);
|
|
1962
2091
|
}
|
|
1963
2092
|
// src/exceptions/exception.ts
|
|
1964
2093
|
var LogixiaException = class extends Error {
|
|
2094
|
+
/** @readonly The machine-readable error code supplied by the caller. */
|
|
2095
|
+
errorCode;
|
|
2096
|
+
/** @readonly The error type category supplied by the caller. */
|
|
2097
|
+
errorType;
|
|
2098
|
+
/** @readonly HTTP status code to respond with. */
|
|
2099
|
+
httpStatus;
|
|
2100
|
+
/** @readonly Field pointer that caused this error (Stripe pattern). */
|
|
2101
|
+
param;
|
|
2102
|
+
/** @readonly Field-level validation errors (GitHub pattern). */
|
|
2103
|
+
details;
|
|
2104
|
+
/** @readonly Documentation URL for this error (Twilio pattern). */
|
|
2105
|
+
docUrl;
|
|
2106
|
+
/**
|
|
2107
|
+
* @readonly Extra context for your logger — never serialised into the HTTP response.
|
|
2108
|
+
*/
|
|
2109
|
+
metadata;
|
|
1965
2110
|
constructor(options) {
|
|
1966
2111
|
super(options.message, { cause: options.cause });
|
|
1967
2112
|
this.name = "LogixiaException";
|
|
@@ -2334,4 +2479,4 @@ Object.defineProperty(exports, "usePlugin", {
|
|
|
2334
2479
|
}
|
|
2335
2480
|
});
|
|
2336
2481
|
|
|
2337
|
-
//# sourceMappingURL=builder-
|
|
2482
|
+
//# sourceMappingURL=builder-jMlVYaQa.js.map
|