logixia 1.13.3 → 2.0.4
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 +117 -44
- package/dist/async-context-B05ArHgM.mjs +134 -0
- package/dist/async-context-B05ArHgM.mjs.map +1 -0
- package/dist/async-context-DTQgi8f7.js +150 -0
- package/dist/async-context-DTQgi8f7.js.map +1 -0
- package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
- package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
- package/dist/{azure-monitor.transport-BDFO4F-i.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
- package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
- package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
- package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
- package/dist/{azure-monitor.transport-D5wQEH04.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
- package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
- package/dist/azure.d.mts +1 -2
- package/dist/azure.d.ts +1 -2
- package/dist/azure.js +3 -6
- package/dist/azure.mjs +1 -6
- package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
- package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
- package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
- package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
- package/dist/browser.d.mts +52 -23
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +52 -23
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +460 -62
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +461 -65
- package/dist/browser.mjs.map +1 -1
- package/dist/{nestjs-extras-ImbuDhs1.mjs → builder-D70z6kjj.mjs} +279 -965
- package/dist/builder-D70z6kjj.mjs.map +1 -0
- package/dist/{nestjs-extras-DnJ6vrIC.js → builder-M7NoaugM.js} +421 -1177
- package/dist/builder-M7NoaugM.js.map +1 -0
- package/dist/cli/index.js +86 -67
- package/dist/cloudwatch.d.mts +1 -2
- package/dist/cloudwatch.d.ts +1 -2
- package/dist/cloudwatch.js +3 -7
- package/dist/cloudwatch.mjs +1 -7
- package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
- package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
- package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
- package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
- package/dist/{cloudwatch.transport-B00st6Xv.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
- package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-Blc7Gtxt.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
- package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
- package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
- package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
- package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
- package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
- package/dist/correlation.d.mts +13 -16
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +13 -16
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +58 -9
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +56 -6
- package/dist/correlation.mjs.map +1 -1
- package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
- package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
- package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
- package/dist/entry-fields-RLd1jCoR.js.map +1 -0
- package/dist/gcp.d.mts +1 -2
- package/dist/gcp.d.ts +1 -2
- package/dist/gcp.js +3 -7
- package/dist/gcp.mjs +1 -7
- package/dist/{gcp.transport-m4fVw0b1.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
- package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
- package/dist/{gcp.transport-zzNyIoih.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
- package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
- package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
- package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
- package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
- package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
- package/dist/{index-nZEeCr3X.d.ts → index-DwozbmB4.d.ts} +3 -8
- package/dist/index-DwozbmB4.d.ts.map +1 -0
- package/dist/{index-BPwEisy4.d.mts → index-xqaJtAZn.d.mts} +3 -8
- package/dist/index-xqaJtAZn.d.mts.map +1 -0
- package/dist/index.d.mts +141 -203
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +140 -202
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +196 -381
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -294
- package/dist/index.mjs.map +1 -1
- package/dist/internal-log-b0Vp4qrB.js +183 -0
- package/dist/internal-log-b0Vp4qrB.js.map +1 -0
- package/dist/internal-log-uCSd1PMc.mjs +142 -0
- package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts +365 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts +365 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
- package/dist/middleware.d.mts +10 -12
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +10 -12
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +16 -47
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +13 -45
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +467 -10
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +467 -10
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +889 -43
- package/dist/nest.js.map +1 -0
- package/dist/nest.mjs +850 -9
- package/dist/nest.mjs.map +1 -0
- package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
- package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
- package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
- package/dist/request-trace-wTJdKp6-.js.map +1 -0
- package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
- package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
- package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
- package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
- package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
- package/dist/{search-CHUZPl0h.d.ts → search-BH33XhuU.d.mts} +2 -22
- package/dist/search-BH33XhuU.d.mts.map +1 -0
- package/dist/{search-DjXSn6v5.mjs → search-CWMVYC-R.mjs} +34 -41
- package/dist/search-CWMVYC-R.mjs.map +1 -0
- package/dist/{search-BfBzDIT9.d.mts → search-CazwyX5Z.d.ts} +2 -22
- package/dist/search-CazwyX5Z.d.ts.map +1 -0
- package/dist/{search-B0MH1SJJ.js → search-DUfWuzFP.js} +64 -71
- package/dist/search-DUfWuzFP.js.map +1 -0
- package/dist/search.d.mts +2 -4
- package/dist/search.d.ts +2 -4
- package/dist/search.js +3 -4
- package/dist/search.mjs +1 -4
- package/dist/secret-config-BegMLkYl.mjs +209 -0
- package/dist/secret-config-BegMLkYl.mjs.map +1 -0
- package/dist/secret-config-CBZBs0p1.js +271 -0
- package/dist/secret-config-CBZBs0p1.js.map +1 -0
- package/dist/slack.transport-Ce96JBDk.mjs +824 -0
- package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
- package/dist/slack.transport-Dlx3xvb7.js +847 -0
- package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
- package/dist/slack.transport-DrirgDNy.d.ts +159 -0
- package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
- package/dist/slack.transport-DxHOXlLu.d.mts +159 -0
- package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
- package/dist/testing.d.mts +3 -8
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.d.ts +3 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -4
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +2 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.manager-Crau3Rle.js → transport.manager-DkcEOlqV.js} +331 -234
- package/dist/transport.manager-DkcEOlqV.js.map +1 -0
- package/dist/{transport.manager-CpdVHEGP.mjs → transport.manager-eZ_EeC00.mjs} +274 -178
- package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
- package/dist/{transport.types-CtNr3D7S.d.mts → transport.types-BJVL1QQl.d.mts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
- package/dist/{transport.types-DqVLZTyf.d.ts → transport.types-BJVL1QQl.d.ts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
- package/dist/transports.d.mts +32 -41
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +32 -41
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +12 -12
- package/dist/transports.mjs +7 -12
- package/dist/worker-entry.js +337 -87
- package/dist/worker.d.mts +1 -2
- package/dist/worker.d.ts +1 -2
- package/dist/worker.js +3 -4
- package/dist/worker.mjs +1 -4
- package/dist/{worker.transport-Bj-i0P9V.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
- package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
- package/dist/{worker.transport-JP8YHBuU.js → worker.transport-C6GNl_r2.js} +44 -14
- package/dist/worker.transport-C6GNl_r2.js.map +1 -0
- package/dist/{worker.transport-otwhJ_Et.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
- package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
- package/dist/{worker.transport-Bgv9heDI.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
- package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
- package/package.json +36 -19
- package/dist/async-context-BzJrbfQs.mjs +0 -72
- package/dist/async-context-BzJrbfQs.mjs.map +0 -1
- package/dist/async-context-DyQQYq3I.js +0 -92
- package/dist/async-context-DyQQYq3I.js.map +0 -1
- package/dist/azure-monitor.transport-BDFO4F-i.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D5wQEH04.d.mts.map +0 -1
- package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
- package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-B00st6Xv.d.ts.map +0 -1
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-Blc7Gtxt.d.mts.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
- package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
- package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
- package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
- package/dist/gcp.transport-m4fVw0b1.d.ts.map +0 -1
- package/dist/gcp.transport-zzNyIoih.d.mts.map +0 -1
- package/dist/index-BPwEisy4.d.mts.map +0 -1
- package/dist/index-nZEeCr3X.d.ts.map +0 -1
- package/dist/internal-log-BUJYMZbE.js +0 -70
- package/dist/internal-log-BUJYMZbE.js.map +0 -1
- package/dist/internal-log-Cm8SOWSV.mjs +0 -52
- package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
- package/dist/nestjs-extras-DnJ6vrIC.js.map +0 -1
- package/dist/nestjs-extras-ImbuDhs1.mjs.map +0 -1
- package/dist/nestjs-extras-OkC796py.d.mts +0 -725
- package/dist/nestjs-extras-OkC796py.d.mts.map +0 -1
- package/dist/nestjs-extras-mKrHE9S6.d.ts +0 -725
- package/dist/nestjs-extras-mKrHE9S6.d.ts.map +0 -1
- package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
- package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
- package/dist/search-B0MH1SJJ.js.map +0 -1
- package/dist/search-BfBzDIT9.d.mts.map +0 -1
- package/dist/search-CHUZPl0h.d.ts.map +0 -1
- package/dist/search-DjXSn6v5.mjs.map +0 -1
- package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
- package/dist/trace.utils-DpBOLDtq.js.map +0 -1
- package/dist/transport.manager-CpdVHEGP.mjs.map +0 -1
- package/dist/transport.manager-Crau3Rle.js.map +0 -1
- package/dist/transport.types-CtNr3D7S.d.mts.map +0 -1
- package/dist/transport.types-DqVLZTyf.d.ts.map +0 -1
- package/dist/worker.transport-Bgv9heDI.d.mts.map +0 -1
- package/dist/worker.transport-Bj-i0P9V.d.ts.map +0 -1
- package/dist/worker.transport-JP8YHBuU.js.map +0 -1
- package/dist/worker.transport-otwhJ_Et.mjs.map +0 -1
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,258 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
// src/utils/sensitive-names.ts
|
|
3
|
+
/**
|
|
4
|
+
* The one list of sensitive names. Log redaction (redact.utils), the HTTP logger
|
|
5
|
+
* middleware and transport secret handling (transports/secret-config) all read it,
|
|
6
|
+
* so the lists cannot drift. No imports: safe from any module, including browser code.
|
|
7
|
+
*/
|
|
8
|
+
/** Field names redacted by name, wherever they appear in logged data. */
|
|
9
|
+
const SENSITIVE_KEY_NAMES = [
|
|
10
|
+
"password",
|
|
11
|
+
"passwd",
|
|
12
|
+
"secret",
|
|
13
|
+
"token",
|
|
14
|
+
"apiKey",
|
|
15
|
+
"api_key",
|
|
16
|
+
"accessToken",
|
|
17
|
+
"access_token",
|
|
18
|
+
"refreshToken",
|
|
19
|
+
"refresh_token",
|
|
20
|
+
"authorization",
|
|
21
|
+
"credentials",
|
|
22
|
+
"privateKey",
|
|
23
|
+
"private_key",
|
|
24
|
+
"clientSecret",
|
|
25
|
+
"client_secret",
|
|
26
|
+
"cookie",
|
|
27
|
+
"set-cookie",
|
|
28
|
+
"x-api-key",
|
|
29
|
+
"session",
|
|
30
|
+
"proxy-authorization",
|
|
31
|
+
"x-auth-token",
|
|
32
|
+
"x-access-token",
|
|
33
|
+
"aws_secret_access_key",
|
|
34
|
+
"awsSecretAccessKey",
|
|
35
|
+
"secretAccessKey"
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Extra names that only mean "secret" inside transport configuration, where
|
|
39
|
+
* short words like `key` or `signature` are credentials, not log fields.
|
|
40
|
+
*/
|
|
41
|
+
const TRANSPORT_CONFIG_SECRET_NAMES = [
|
|
42
|
+
"writeKey",
|
|
43
|
+
"apiSecret",
|
|
44
|
+
"connectionString",
|
|
45
|
+
"sessionToken",
|
|
46
|
+
"passphrase",
|
|
47
|
+
"signature",
|
|
48
|
+
"pwd",
|
|
49
|
+
"pfx",
|
|
50
|
+
"cert",
|
|
51
|
+
"key",
|
|
52
|
+
"auth"
|
|
53
|
+
];
|
|
54
|
+
/** Query-string parameters whose values are never logged. */
|
|
55
|
+
const DEFAULT_REDACT_QUERY_PARAMS = [
|
|
56
|
+
"token",
|
|
57
|
+
"access_token",
|
|
58
|
+
"refresh_token",
|
|
59
|
+
"code",
|
|
60
|
+
"password",
|
|
61
|
+
"secret",
|
|
62
|
+
"api_key",
|
|
63
|
+
"apikey",
|
|
64
|
+
"key",
|
|
65
|
+
"signature",
|
|
66
|
+
"sig",
|
|
67
|
+
"auth"
|
|
68
|
+
];
|
|
69
|
+
// src/transports/secret-config.ts
|
|
70
|
+
/**
|
|
71
|
+
* Keeps credentials out of serialized transport output and error text.
|
|
72
|
+
*
|
|
73
|
+
* `protectSecrets()` replaces each listed field with a non-enumerable accessor backed
|
|
74
|
+
* by a WeakMap, whether or not the field is assigned yet, so later assignments (a
|
|
75
|
+
* connection opened on first write, a refreshed token) stay hidden too. It also
|
|
76
|
+
* installs `toJSON()` and a Node inspect hook returning a redacted view: scalar
|
|
77
|
+
* fields stay for debugging, secret-looking keys become '[REDACTED]', URLs lose
|
|
78
|
+
* userinfo, query and fragment. No Node imports, so browser bundles can use it.
|
|
79
|
+
*/
|
|
80
|
+
const REDACTED = "[REDACTED]";
|
|
81
|
+
const INSPECT_CUSTOM = Symbol.for("nodejs.util.inspect.custom");
|
|
82
|
+
const MAX_DEPTH = 4;
|
|
83
|
+
const SCHEME_PREFIX = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
84
|
+
function normalizeName(name) {
|
|
85
|
+
return name.toLowerCase().replaceAll("-", "").replaceAll("_", "");
|
|
86
|
+
}
|
|
87
|
+
const SECRET_NAMES = [...SENSITIVE_KEY_NAMES, ...TRANSPORT_CONFIG_SECRET_NAMES].map(normalizeName);
|
|
88
|
+
new Set(DEFAULT_REDACT_QUERY_PARAMS.map(normalizeName));
|
|
89
|
+
/** Exact match for short names (`key`, `pfx`), suffix match for longer ones (`azureClientSecret`). */
|
|
90
|
+
function isSecretKey(key) {
|
|
91
|
+
const name = normalizeName(key);
|
|
92
|
+
return SECRET_NAMES.some((n) => name === n || n.length >= 5 && name.endsWith(n));
|
|
93
|
+
}
|
|
94
|
+
function isUrlKey(key) {
|
|
95
|
+
return /url|uri|endpoint|href/i.test(key);
|
|
96
|
+
}
|
|
97
|
+
function isPlainObject(value) {
|
|
98
|
+
const proto = Object.getPrototypeOf(value);
|
|
99
|
+
return proto === Object.prototype || proto === null;
|
|
100
|
+
}
|
|
101
|
+
/** Absolute URL: `scheme://host` only. Relative or unparseable: path kept, query and fragment cut. */
|
|
102
|
+
function redactUrl(raw) {
|
|
103
|
+
if (typeof raw !== "string") return `${raw.protocol}//${raw.host}`;
|
|
104
|
+
if (SCHEME_PREFIX.test(raw)) try {
|
|
105
|
+
const url = new URL(raw);
|
|
106
|
+
return `${url.protocol}//${url.host}`;
|
|
107
|
+
} catch {
|
|
108
|
+
return REDACTED;
|
|
109
|
+
}
|
|
110
|
+
return raw.split(/[?#]/, 1)[0] ?? "";
|
|
111
|
+
}
|
|
112
|
+
function redactHeaders(headers) {
|
|
113
|
+
if (!headers || typeof headers !== "object") return headers;
|
|
114
|
+
return Object.fromEntries(Object.keys(headers).map((name) => [name, REDACTED]));
|
|
115
|
+
}
|
|
116
|
+
/** Redacted deep copy of a config-like value. Never throws, never returns a secret. */
|
|
117
|
+
function redactConfig(value, depth = 0, key = "") {
|
|
118
|
+
var _value$constructor;
|
|
119
|
+
if (value === null || value === void 0) return value;
|
|
120
|
+
if (typeof value === "string") return SCHEME_PREFIX.test(value) || isUrlKey(key) ? redactUrl(value) : value;
|
|
121
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
122
|
+
if (typeof value === "function") return "[Function]";
|
|
123
|
+
if (typeof value !== "object") return "[Unserializable]";
|
|
124
|
+
if (typeof URL !== "undefined" && value instanceof URL) return redactUrl(value);
|
|
125
|
+
if (Array.isArray(value)) return depth >= MAX_DEPTH ? "[Array]" : value.map((v) => redactConfig(v, depth + 1, key));
|
|
126
|
+
if (!isPlainObject(value) || depth >= MAX_DEPTH) return `[${((_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name) ?? "Object"}]`;
|
|
127
|
+
const out = {};
|
|
128
|
+
for (const [name, inner] of Object.entries(value)) if (isSecretKey(name)) out[name] = inner === void 0 ? void 0 : REDACTED;
|
|
129
|
+
else if (name.toLowerCase() === "headers") out[name] = redactHeaders(inner);
|
|
130
|
+
else out[name] = redactConfig(inner, depth + 1, name);
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
const hiddenKeys = /* @__PURE__ */ new WeakMap();
|
|
134
|
+
const hiddenValues = /* @__PURE__ */ new WeakMap();
|
|
135
|
+
function viewOf(target) {
|
|
136
|
+
var _target$constructor;
|
|
137
|
+
const hidden = hiddenKeys.get(target) ?? /* @__PURE__ */ new Set();
|
|
138
|
+
const values = hiddenValues.get(target);
|
|
139
|
+
const view = { class: (_target$constructor = target.constructor) === null || _target$constructor === void 0 ? void 0 : _target$constructor.name };
|
|
140
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(target), ...hidden])) {
|
|
141
|
+
const inner = hidden.has(key) ? values === null || values === void 0 ? void 0 : values.get(key) : target[key];
|
|
142
|
+
if (isSecretKey(key)) view[key] = inner === void 0 ? void 0 : REDACTED;
|
|
143
|
+
else if (key.toLowerCase() === "headers") view[key] = redactHeaders(inner);
|
|
144
|
+
else if (inner !== null && typeof inner === "object" && !hidden.has(key) && !(inner instanceof URL)) view[key] = "[Object]";
|
|
145
|
+
else if (hidden.has(key) && typeof inner === "string" && !isUrlKey(key)) view[key] = REDACTED;
|
|
146
|
+
else view[key] = redactConfig(inner, 0, key);
|
|
147
|
+
}
|
|
148
|
+
return view;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Hides `keys` on `target` (assigned or not yet) and gives it a redacted `toJSON()` /
|
|
152
|
+
* inspect view. Fields stay readable and writable. Safe to call more than once.
|
|
153
|
+
* Throws when the target cannot carry the protection (frozen or sealed), instead of
|
|
154
|
+
* silently leaving the secret enumerable.
|
|
155
|
+
*/
|
|
156
|
+
function protectSecrets(target, keys) {
|
|
157
|
+
if (!Object.isExtensible(target)) {
|
|
158
|
+
var _target$constructor2;
|
|
159
|
+
throw new TypeError(`protectSecrets: ${((_target$constructor2 = target.constructor) === null || _target$constructor2 === void 0 ? void 0 : _target$constructor2.name) ?? "object"} is not extensible`);
|
|
160
|
+
}
|
|
161
|
+
let hidden = hiddenKeys.get(target);
|
|
162
|
+
let values = hiddenValues.get(target);
|
|
163
|
+
if (!hidden || !values) {
|
|
164
|
+
hidden = /* @__PURE__ */ new Set();
|
|
165
|
+
values = /* @__PURE__ */ new Map();
|
|
166
|
+
hiddenKeys.set(target, hidden);
|
|
167
|
+
hiddenValues.set(target, values);
|
|
168
|
+
const view = () => viewOf(target);
|
|
169
|
+
Object.defineProperty(target, "toJSON", {
|
|
170
|
+
value: view,
|
|
171
|
+
enumerable: false,
|
|
172
|
+
configurable: true
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(target, INSPECT_CUSTOM, {
|
|
175
|
+
value: view,
|
|
176
|
+
enumerable: false,
|
|
177
|
+
configurable: true
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const store = values;
|
|
181
|
+
for (const key of keys) {
|
|
182
|
+
if (hidden.has(key)) continue;
|
|
183
|
+
const desc = Object.getOwnPropertyDescriptor(target, key);
|
|
184
|
+
if (desc && !desc.configurable) throw new TypeError(`protectSecrets: "${key}" is not configurable`);
|
|
185
|
+
if (desc && "value" in desc) store.set(key, desc.value);
|
|
186
|
+
hidden.add(key);
|
|
187
|
+
Object.defineProperty(target, key, {
|
|
188
|
+
enumerable: false,
|
|
189
|
+
configurable: true,
|
|
190
|
+
get: () => store.get(key),
|
|
191
|
+
set: (next) => void store.set(key, next)
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// src/utils/internal-log.ts
|
|
196
|
+
/**
|
|
197
|
+
* Internal logging helpers for use within the logixia library itself.
|
|
198
|
+
*
|
|
199
|
+
* These functions write directly to stderr/stdout without going through
|
|
200
|
+
* LogixiaLogger — this avoids circular dependencies and ensures internal
|
|
201
|
+
* diagnostics still surface even when the logger is misconfigured.
|
|
202
|
+
*
|
|
203
|
+
* Library code must NEVER call console.log/warn/error directly. Use these
|
|
204
|
+
* helpers instead so that internal output can be silenced in tests by setting
|
|
205
|
+
* the LOGIXIA_SILENT_INTERNAL=1 environment variable.
|
|
206
|
+
*/
|
|
207
|
+
/**
|
|
208
|
+
* Read the silence flag on each call rather than caching it at import time, so
|
|
209
|
+
* setting LOGIXIA_SILENT_INTERNAL=1 AFTER the module is first imported (e.g. in
|
|
210
|
+
* a test setup file) still takes effect — the documented test-silencing
|
|
211
|
+
* behavior was previously unreliable because the value was frozen at load.
|
|
212
|
+
*/
|
|
213
|
+
function isSilent() {
|
|
214
|
+
var _process$env;
|
|
215
|
+
if (typeof process !== "undefined" && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.LOGIXIA_SILENT_INTERNAL) === "1") return true;
|
|
216
|
+
const flag = globalThis["LOGIXIA_SILENT_INTERNAL"];
|
|
217
|
+
return flag === "1" || flag === 1 || flag === true;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Write a line to stderr, falling back to the matching console method where
|
|
221
|
+
* `process` is unavailable (browsers, Cloudflare Workers, Deno without Node compat).
|
|
222
|
+
*/
|
|
223
|
+
function writeLine(method, line) {
|
|
224
|
+
var _process$stderr;
|
|
225
|
+
if (typeof process !== "undefined" && typeof ((_process$stderr = process.stderr) === null || _process$stderr === void 0 ? void 0 : _process$stderr.write) === "function") process.stderr.write(`${line}\n`);
|
|
226
|
+
else if (typeof console !== "undefined" && typeof console[method] === "function") console[method](line);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Emit an internal debug/info message to stderr.
|
|
230
|
+
* Use for field-enable/disable notifications that a developer might want to see
|
|
231
|
+
* during development but should not appear in production log streams.
|
|
232
|
+
*/
|
|
233
|
+
function internalLog(message) {
|
|
234
|
+
if (!isSilent()) writeLine("log", `[logixia] ${message}`);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Emit an internal warning to stderr.
|
|
238
|
+
* Use when something is misconfigured but logixia can continue operating.
|
|
239
|
+
*/
|
|
240
|
+
function internalWarn(message) {
|
|
241
|
+
if (!isSilent()) writeLine("warn", `[logixia:warn] ${message}`);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Emit an internal error to stderr.
|
|
245
|
+
* Use when a transport write fails or a serious internal error occurs.
|
|
246
|
+
*/
|
|
247
|
+
function internalError(message, error) {
|
|
248
|
+
if (!isSilent()) {
|
|
249
|
+
let errStr = "";
|
|
250
|
+
if (error instanceof Error) errStr = ` — ${error.message}`;
|
|
251
|
+
else if (error != null) errStr = ` — ${String(error)}`;
|
|
252
|
+
writeLine("error", `[logixia:error] ${message}${errStr}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// src/utils/safe-stringify.ts
|
|
3
256
|
/** Build a JSONPath like `$["a"][0]["b"]` for a decycle pointer. */
|
|
4
257
|
function jsonPath(parts) {
|
|
5
258
|
let path = "$";
|
|
@@ -83,9 +336,7 @@ function stringifyForLog(value) {
|
|
|
83
336
|
}
|
|
84
337
|
}
|
|
85
338
|
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/utils/otel.ts
|
|
339
|
+
// src/utils/otel.ts
|
|
89
340
|
let _otelApi;
|
|
90
341
|
function tryLoadOtelApi() {
|
|
91
342
|
if (_otelApi !== void 0) return _otelApi;
|
|
@@ -149,7 +400,6 @@ function getOtelMetaFields(opts = {}) {
|
|
|
149
400
|
[traceFlagsField]: ctx.traceFlags
|
|
150
401
|
};
|
|
151
402
|
}
|
|
152
|
-
let _bridgeOptions = null;
|
|
153
403
|
/**
|
|
154
404
|
* Initialise the global OTel bridge.
|
|
155
405
|
*
|
|
@@ -163,48 +413,59 @@ let _bridgeOptions = null;
|
|
|
163
413
|
* initOtelBridge();
|
|
164
414
|
* ```
|
|
165
415
|
*/
|
|
166
|
-
function initOtelBridge(opts = {}) {
|
|
167
|
-
_bridgeOptions = opts;
|
|
168
|
-
}
|
|
416
|
+
function initOtelBridge(opts = {}) {}
|
|
169
417
|
/**
|
|
170
418
|
* Disable the OTel bridge (useful for tests).
|
|
171
419
|
*/
|
|
172
|
-
function disableOtelBridge() {
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region src/utils/internal-log.ts
|
|
420
|
+
function disableOtelBridge() {}
|
|
421
|
+
// src/utils/typed-logger.ts
|
|
178
422
|
/**
|
|
179
|
-
*
|
|
423
|
+
* logixia — TypeScript typed log fields
|
|
180
424
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* diagnostics still surface even when the logger is misconfigured.
|
|
425
|
+
* Solves the type-safety gap: standard `Record<string, unknown>` metadata gives
|
|
426
|
+
* zero IDE autocomplete and lets typos slip silently into production logs.
|
|
184
427
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
*
|
|
200
|
-
*
|
|
428
|
+
* Two complementary utilities:
|
|
429
|
+
*
|
|
430
|
+
* 1. `createTypedLogger<TFields>()` — wraps any IBaseLogger so that the second
|
|
431
|
+
* argument of every log method is constrained to `TFields` (a typed object).
|
|
432
|
+
* Compile-time safety, zero runtime overhead.
|
|
433
|
+
*
|
|
434
|
+
* 2. `defineLogSchema<TFields>(schema)` — declares expected fields with optional
|
|
435
|
+
* validators. In development (NODE_ENV !== 'production') every log call is
|
|
436
|
+
* validated against the schema and a warning is emitted for missing required
|
|
437
|
+
* fields or type mismatches.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* import { createTypedLogger, defineLogSchema } from 'logixia';
|
|
442
|
+
*
|
|
443
|
+
* interface OrderFields {
|
|
444
|
+
* orderId: string;
|
|
445
|
+
* userId: string;
|
|
446
|
+
* amount?: number;
|
|
447
|
+
* currency?: string;
|
|
448
|
+
* }
|
|
449
|
+
*
|
|
450
|
+
* const schema = defineLogSchema<OrderFields>({
|
|
451
|
+
* orderId: { type: 'string', required: true },
|
|
452
|
+
* userId: { type: 'string', required: true },
|
|
453
|
+
* amount: { type: 'number' },
|
|
454
|
+
* currency: { type: 'string' },
|
|
455
|
+
* });
|
|
456
|
+
*
|
|
457
|
+
* const orderLogger = createTypedLogger<OrderFields>(baseLogger, schema);
|
|
458
|
+
* await orderLogger.info('Order created', { orderId: 'ord_123', userId: 'usr_456', amount: 99.99 });
|
|
459
|
+
* // ^^^^ fully typed autocomplete ^^^^
|
|
460
|
+
* ```
|
|
201
461
|
*/
|
|
202
|
-
function
|
|
203
|
-
|
|
462
|
+
function isProduction() {
|
|
463
|
+
try {
|
|
464
|
+
return process.env.NODE_ENV === "production";
|
|
465
|
+
} catch {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
204
468
|
}
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/utils/typed-logger.ts
|
|
208
469
|
/**
|
|
209
470
|
* Define a typed schema for a category of log entries.
|
|
210
471
|
*
|
|
@@ -215,7 +476,7 @@ function defineLogSchema(fields) {
|
|
|
215
476
|
return {
|
|
216
477
|
fields,
|
|
217
478
|
validate(payload) {
|
|
218
|
-
if (
|
|
479
|
+
if (isProduction()) return [];
|
|
219
480
|
const warnings = [];
|
|
220
481
|
for (const [key, def] of Object.entries(fields)) {
|
|
221
482
|
const value = payload[key];
|
|
@@ -267,9 +528,42 @@ function createTypedLogger(logger, schema) {
|
|
|
267
528
|
trace: (m, d) => withValidation("trace", (logger.trace ?? logger.debug).bind(logger), m, d)
|
|
268
529
|
};
|
|
269
530
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
531
|
+
// src/browser.ts
|
|
532
|
+
/**
|
|
533
|
+
* logixia — Browser / Edge Runtime entry point
|
|
534
|
+
*
|
|
535
|
+
* This module is the browser-safe subset of logixia. It contains **no**
|
|
536
|
+
* references to Node.js built-ins (`node:fs`, `node:http`, `node:worker_threads`,
|
|
537
|
+
* `node:crypto`, `node:async_hooks`) so it can be bundled for:
|
|
538
|
+
*
|
|
539
|
+
* - Browser (Webpack / Vite / esbuild)
|
|
540
|
+
* - Cloudflare Workers / Vercel Edge Functions
|
|
541
|
+
* - Deno (via ESM import)
|
|
542
|
+
* - Bun (core subset, no file/DB transports)
|
|
543
|
+
*
|
|
544
|
+
* Excluded from this entry: FileTransport, DatabaseTransport, WorkerTransport,
|
|
545
|
+
* CloudWatchTransport, GCPTransport, AzureMonitorTransport, and anything that
|
|
546
|
+
* requires `AsyncLocalStorage`.
|
|
547
|
+
*
|
|
548
|
+
* @example Basic browser usage
|
|
549
|
+
* ```ts
|
|
550
|
+
* import { createBrowserLogger, BrowserConsoleTransport } from 'logixia/browser';
|
|
551
|
+
*
|
|
552
|
+
* const logger = createBrowserLogger({ appName: 'my-app' });
|
|
553
|
+
* logger.info('Page loaded', { url: location.href });
|
|
554
|
+
* ```
|
|
555
|
+
*
|
|
556
|
+
* @example Custom transport in browser
|
|
557
|
+
* ```ts
|
|
558
|
+
* import { createBrowserLogger, BrowserConsoleTransport } from 'logixia/browser';
|
|
559
|
+
*
|
|
560
|
+
* const logger = createBrowserLogger({
|
|
561
|
+
* appName: 'my-app',
|
|
562
|
+
* json: false, // pretty-print in devtools
|
|
563
|
+
* level: 'debug',
|
|
564
|
+
* });
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
273
567
|
const LEVEL_ORDER = {
|
|
274
568
|
verbose: 0,
|
|
275
569
|
debug: 1,
|
|
@@ -364,7 +658,7 @@ function validateRemoteUrl(raw) {
|
|
|
364
658
|
try {
|
|
365
659
|
parsed = new URL(raw);
|
|
366
660
|
} catch {
|
|
367
|
-
throw new TypeError(`BrowserRemoteTransport: invalid url
|
|
661
|
+
throw new TypeError(`BrowserRemoteTransport: invalid url [redacted]`);
|
|
368
662
|
}
|
|
369
663
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`BrowserRemoteTransport: url scheme "${parsed.protocol}" is not allowed; use http: or https:`);
|
|
370
664
|
return raw;
|
|
@@ -377,6 +671,34 @@ function validateRemoteUrl(raw) {
|
|
|
377
671
|
function byteLength(s) {
|
|
378
672
|
return new TextEncoder().encode(s).length;
|
|
379
673
|
}
|
|
674
|
+
const FAILURE_REPORT_INTERVAL_MS = 6e4;
|
|
675
|
+
/**
|
|
676
|
+
* Error name/code, HTTP status and host only. The error message is never
|
|
677
|
+
* included: runtimes embed request URLs (absolute or relative) and header
|
|
678
|
+
* values in it.
|
|
679
|
+
*/
|
|
680
|
+
function describeFailure(error, url) {
|
|
681
|
+
let host = "relative endpoint";
|
|
682
|
+
try {
|
|
683
|
+
host = `host ${new URL(url).host}`;
|
|
684
|
+
} catch {}
|
|
685
|
+
const e = error;
|
|
686
|
+
const parts = [];
|
|
687
|
+
if (e && typeof e.name === "string") parts.push(e.name);
|
|
688
|
+
if (e && typeof e.code === "string") parts.push(e.code);
|
|
689
|
+
if (e && typeof e.status === "number") parts.push(`HTTP ${e.status}`);
|
|
690
|
+
parts.push(host);
|
|
691
|
+
return parts.join(" ");
|
|
692
|
+
}
|
|
693
|
+
/** True only in a real browser page, where console noise reaches end users. */
|
|
694
|
+
function isBrowserPage() {
|
|
695
|
+
const g = globalThis;
|
|
696
|
+
return typeof g["window"] !== "undefined" && typeof g["document"] !== "undefined";
|
|
697
|
+
}
|
|
698
|
+
function isKeepaliveError(error) {
|
|
699
|
+
const message = error === null || error === void 0 ? void 0 : error.message;
|
|
700
|
+
return typeof message === "string" && /keepalive/i.test(message);
|
|
701
|
+
}
|
|
380
702
|
/**
|
|
381
703
|
* Browser transport that batches log entries and sends them to a remote
|
|
382
704
|
* HTTP endpoint via `fetch` (available in all modern browsers and Edge runtimes).
|
|
@@ -398,14 +720,21 @@ var BrowserRemoteTransport = class {
|
|
|
398
720
|
constructor(options) {
|
|
399
721
|
this.name = "browser-remote";
|
|
400
722
|
this.batch = [];
|
|
723
|
+
this.keepaliveSupported = true;
|
|
724
|
+
this.failedFlushCount = 0;
|
|
401
725
|
this.timer = null;
|
|
402
726
|
this.droppedEntries = 0;
|
|
727
|
+
this.reporting = false;
|
|
728
|
+
this.failureReported = false;
|
|
729
|
+
this.silent = options.silent ?? isBrowserPage();
|
|
730
|
+
this.onError = options.onError;
|
|
403
731
|
this.url = validateRemoteUrl(options.url);
|
|
404
732
|
this.headers = options.headers ?? {};
|
|
405
733
|
this.batchSize = options.batchSize ?? 100;
|
|
406
734
|
this.flushIntervalMs = options.flushIntervalMs ?? 5e3;
|
|
407
735
|
this.maxBufferSize = options.maxBufferSize ?? 1e3;
|
|
408
736
|
if (options.level !== void 0) this.level = options.level;
|
|
737
|
+
protectSecrets(this, ["headers", "url"]);
|
|
409
738
|
this.scheduleFlush();
|
|
410
739
|
}
|
|
411
740
|
/**
|
|
@@ -416,7 +745,23 @@ var BrowserRemoteTransport = class {
|
|
|
416
745
|
get dropped() {
|
|
417
746
|
return this.droppedEntries;
|
|
418
747
|
}
|
|
748
|
+
/** Number of flush attempts that failed (network error or non-OK HTTP status). */
|
|
749
|
+
get failedFlushes() {
|
|
750
|
+
return this.failedFlushCount;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* The most recent failure from a flush, if any: the raw fetch error (which on
|
|
754
|
+
* some runtimes embeds the request URL, so do not log it blindly) or an
|
|
755
|
+
* `Error` carrying only the HTTP status.
|
|
756
|
+
*/
|
|
757
|
+
get lastError() {
|
|
758
|
+
return this.lastFlushError;
|
|
759
|
+
}
|
|
419
760
|
write(entry) {
|
|
761
|
+
if (this.reporting) {
|
|
762
|
+
this.droppedEntries += 1;
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
420
765
|
this.batch.push(entry);
|
|
421
766
|
while (this.batch.length > this.maxBufferSize) {
|
|
422
767
|
this.batch.shift();
|
|
@@ -431,24 +776,75 @@ var BrowserRemoteTransport = class {
|
|
|
431
776
|
const keepalive = byteLength(body) < 6e4;
|
|
432
777
|
let res;
|
|
433
778
|
try {
|
|
434
|
-
res = await
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
779
|
+
res = await this.send(body, this.keepaliveSupported ? keepalive : void 0);
|
|
780
|
+
} catch (error) {
|
|
781
|
+
if (this.keepaliveSupported && isKeepaliveError(error)) {
|
|
782
|
+
this.keepaliveSupported = false;
|
|
783
|
+
try {
|
|
784
|
+
res = await this.send(body);
|
|
785
|
+
} catch (retryError) {
|
|
786
|
+
this.recordFailure(entries, retryError);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
} else {
|
|
790
|
+
this.recordFailure(entries, error);
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
446
793
|
}
|
|
447
794
|
if (!res.ok) {
|
|
448
|
-
|
|
449
|
-
|
|
795
|
+
const failure = Object.assign(/* @__PURE__ */ new Error(`HTTP ${res.status}`), { status: res.status });
|
|
796
|
+
if (res.status >= 500 || res.status === 429) this.recordFailure(entries, failure);
|
|
797
|
+
else {
|
|
798
|
+
this.droppedEntries += entries.length;
|
|
799
|
+
this.recordFailure([], failure);
|
|
800
|
+
}
|
|
450
801
|
return;
|
|
451
802
|
}
|
|
803
|
+
this.reportRecovery();
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
send(body, keepalive) {
|
|
807
|
+
return fetch(this.url, {
|
|
808
|
+
method: "POST",
|
|
809
|
+
headers: {
|
|
810
|
+
"Content-Type": "application/json",
|
|
811
|
+
...this.headers
|
|
812
|
+
},
|
|
813
|
+
body,
|
|
814
|
+
...keepalive !== void 0 ? { keepalive } : {}
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
recordFailure(entries, error) {
|
|
818
|
+
this.batch.unshift(...entries);
|
|
819
|
+
this.failedFlushCount += 1;
|
|
820
|
+
this.lastFlushError = error;
|
|
821
|
+
const now = Date.now();
|
|
822
|
+
const shouldReport = this.lastReportAt === void 0 || now - this.lastReportAt >= FAILURE_REPORT_INTERVAL_MS;
|
|
823
|
+
this.guarded(() => {
|
|
824
|
+
if (this.onError) try {
|
|
825
|
+
this.onError(error);
|
|
826
|
+
} catch {}
|
|
827
|
+
if (shouldReport && !this.silent) {
|
|
828
|
+
this.lastReportAt = now;
|
|
829
|
+
this.failureReported = true;
|
|
830
|
+
internalError(`BrowserRemoteTransport flush failed (${describeFailure(error, this.url)})`);
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
reportRecovery() {
|
|
835
|
+
if (!this.failureReported) return;
|
|
836
|
+
this.failureReported = false;
|
|
837
|
+
const now = Date.now();
|
|
838
|
+
if (this.lastRecoveryAt !== void 0 && now - this.lastRecoveryAt < FAILURE_REPORT_INTERVAL_MS) return;
|
|
839
|
+
this.lastRecoveryAt = now;
|
|
840
|
+
this.guarded(() => internalLog("BrowserRemoteTransport delivery recovered"));
|
|
841
|
+
}
|
|
842
|
+
guarded(fn) {
|
|
843
|
+
this.reporting = true;
|
|
844
|
+
try {
|
|
845
|
+
fn();
|
|
846
|
+
} finally {
|
|
847
|
+
this.reporting = false;
|
|
452
848
|
}
|
|
453
849
|
}
|
|
454
850
|
scheduleFlush() {
|
|
@@ -486,7 +882,10 @@ var BrowserLogger = class BrowserLogger {
|
|
|
486
882
|
context: config.context
|
|
487
883
|
};
|
|
488
884
|
if (config.silent) this.transports = [];
|
|
489
|
-
else
|
|
885
|
+
else {
|
|
886
|
+
const builtIn = new BrowserConsoleTransport({ json: this.config.json });
|
|
887
|
+
this.transports = [builtIn, ...config.transports ?? []];
|
|
888
|
+
}
|
|
490
889
|
}
|
|
491
890
|
verbose(message, payload) {
|
|
492
891
|
this.emit("verbose", message, payload);
|
|
@@ -574,8 +973,6 @@ function createBrowserLogger(config) {
|
|
|
574
973
|
* ```
|
|
575
974
|
*/
|
|
576
975
|
const browserLogger = new BrowserLogger({ appName: "App" });
|
|
577
|
-
|
|
578
|
-
//#endregion
|
|
579
976
|
exports.BrowserConsoleTransport = BrowserConsoleTransport;
|
|
580
977
|
exports.BrowserLogger = BrowserLogger;
|
|
581
978
|
exports.BrowserRemoteTransport = BrowserRemoteTransport;
|
|
@@ -587,4 +984,5 @@ exports.disableOtelBridge = disableOtelBridge;
|
|
|
587
984
|
exports.getActiveOtelContext = getActiveOtelContext;
|
|
588
985
|
exports.getOtelMetaFields = getOtelMetaFields;
|
|
589
986
|
exports.initOtelBridge = initOtelBridge;
|
|
987
|
+
|
|
590
988
|
//# sourceMappingURL=browser.js.map
|