logixia 2.0.0 → 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 +46 -29
- 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-Cn_3Usvu.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-D7Da4RAb.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 +45 -25
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +45 -25
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +420 -53
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +421 -56
- package/dist/browser.mjs.map +1 -1
- package/dist/{builder-0gEzRopq.mjs → builder-D70z6kjj.mjs} +212 -104
- package/dist/builder-D70z6kjj.mjs.map +1 -0
- package/dist/{builder-D44QktIo.js → builder-M7NoaugM.js} +355 -249
- package/dist/builder-M7NoaugM.js.map +1 -0
- package/dist/cli/index.js +59 -59
- 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-DsEq633o.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
- package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-UlyZFWMn.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-B7oc97sG.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
- package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
- package/dist/{gcp.transport-GrJurKo8.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-DhIoploR.d.ts → index-DwozbmB4.d.ts} +3 -8
- package/dist/index-DwozbmB4.d.ts.map +1 -0
- package/dist/{index-3mw5gaCw.d.mts → index-xqaJtAZn.d.mts} +3 -8
- package/dist/index-xqaJtAZn.d.mts.map +1 -0
- package/dist/index.d.mts +106 -165
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +105 -164
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +164 -261
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -243
- 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-UVeN-mQm.d.ts → logitron-logger-D2B75Oc7.d.ts} +116 -8
- package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
- package/dist/{logitron-logger-BFDSO8Io.d.mts → logitron-logger-oEd6wNhf.d.mts} +116 -8
- 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 +26 -44
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +26 -44
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +116 -132
- package/dist/nest.js.map +1 -1
- package/dist/nest.mjs +59 -73
- package/dist/nest.mjs.map +1 -1
- 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-CNh9uVwR.d.ts → search-BH33XhuU.d.mts} +2 -22
- package/dist/search-BH33XhuU.d.mts.map +1 -0
- package/dist/{search-BFbu_oVn.mjs → search-CWMVYC-R.mjs} +22 -39
- package/dist/search-CWMVYC-R.mjs.map +1 -0
- package/dist/{search-DXANsQ2n.d.mts → search-CazwyX5Z.d.ts} +2 -22
- package/dist/search-CazwyX5Z.d.ts.map +1 -0
- package/dist/{search-C4V0OMEn.js → search-DUfWuzFP.js} +52 -69
- 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-Bzw7sucI.mjs → slack.transport-Ce96JBDk.mjs} +212 -31
- package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
- package/dist/{slack.transport-BfJRouB2.js → slack.transport-Dlx3xvb7.js} +234 -41
- package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
- package/dist/{slack.transport-BZzoXDPn.d.mts → slack.transport-DrirgDNy.d.ts} +56 -9
- package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
- package/dist/{slack.transport-CXjQYOes.d.ts → slack.transport-DxHOXlLu.d.mts} +56 -9
- 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-CXbKKdVE.js → transport.manager-DkcEOlqV.js} +164 -160
- package/dist/transport.manager-DkcEOlqV.js.map +1 -0
- package/dist/{transport.manager-BiuCAJd2.mjs → transport.manager-eZ_EeC00.mjs} +108 -99
- package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
- package/dist/{transport.types-CGoHpWQR.d.ts → transport.types-BJVL1QQl.d.mts} +1 -3
- package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
- package/dist/{transport.types-BMnurPcc.d.mts → transport.types-BJVL1QQl.d.ts} +1 -3
- package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
- package/dist/transports.d.mts +22 -36
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +22 -36
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +10 -13
- package/dist/transports.mjs +7 -13
- 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-CdzSZJmw.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
- package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
- package/dist/{worker.transport-BdPxu3PN.js → worker.transport-C6GNl_r2.js} +44 -14
- package/dist/worker.transport-C6GNl_r2.js.map +1 -0
- package/dist/{worker.transport-lPxO2MVL.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
- package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
- package/dist/{worker.transport-JvGPog3C.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
- package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
- package/package.json +19 -11
- 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-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-Cn_3Usvu.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D7Da4RAb.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/builder-0gEzRopq.mjs.map +0 -1
- package/dist/builder-D44QktIo.js.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/cloudwatch.transport-DsEq633o.d.ts.map +0 -1
- package/dist/cloudwatch.transport-UlyZFWMn.d.mts.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-B7oc97sG.d.ts.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-GrJurKo8.d.mts.map +0 -1
- package/dist/index-3mw5gaCw.d.mts.map +0 -1
- package/dist/index-DhIoploR.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/logitron-logger-BFDSO8Io.d.mts.map +0 -1
- package/dist/logitron-logger-UVeN-mQm.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-BFbu_oVn.mjs.map +0 -1
- package/dist/search-C4V0OMEn.js.map +0 -1
- package/dist/search-CNh9uVwR.d.ts.map +0 -1
- package/dist/search-DXANsQ2n.d.mts.map +0 -1
- package/dist/slack.transport-BZzoXDPn.d.mts.map +0 -1
- package/dist/slack.transport-BfJRouB2.js.map +0 -1
- package/dist/slack.transport-Bzw7sucI.mjs.map +0 -1
- package/dist/slack.transport-CXjQYOes.d.ts.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-BiuCAJd2.mjs.map +0 -1
- package/dist/transport.manager-CXbKKdVE.js.map +0 -1
- package/dist/transport.types-BMnurPcc.d.mts.map +0 -1
- package/dist/transport.types-CGoHpWQR.d.ts.map +0 -1
- package/dist/worker.transport-BdPxu3PN.js.map +0 -1
- package/dist/worker.transport-CdzSZJmw.d.ts.map +0 -1
- package/dist/worker.transport-JvGPog3C.d.mts.map +0 -1
- package/dist/worker.transport-lPxO2MVL.mjs.map +0 -1
package/dist/browser.mjs
CHANGED
|
@@ -1,11 +1,262 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
3
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
-
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
// src/utils/sensitive-names.ts
|
|
7
|
+
/**
|
|
8
|
+
* The one list of sensitive names. Log redaction (redact.utils), the HTTP logger
|
|
9
|
+
* middleware and transport secret handling (transports/secret-config) all read it,
|
|
10
|
+
* so the lists cannot drift. No imports: safe from any module, including browser code.
|
|
11
|
+
*/
|
|
12
|
+
/** Field names redacted by name, wherever they appear in logged data. */
|
|
13
|
+
const SENSITIVE_KEY_NAMES = [
|
|
14
|
+
"password",
|
|
15
|
+
"passwd",
|
|
16
|
+
"secret",
|
|
17
|
+
"token",
|
|
18
|
+
"apiKey",
|
|
19
|
+
"api_key",
|
|
20
|
+
"accessToken",
|
|
21
|
+
"access_token",
|
|
22
|
+
"refreshToken",
|
|
23
|
+
"refresh_token",
|
|
24
|
+
"authorization",
|
|
25
|
+
"credentials",
|
|
26
|
+
"privateKey",
|
|
27
|
+
"private_key",
|
|
28
|
+
"clientSecret",
|
|
29
|
+
"client_secret",
|
|
30
|
+
"cookie",
|
|
31
|
+
"set-cookie",
|
|
32
|
+
"x-api-key",
|
|
33
|
+
"session",
|
|
34
|
+
"proxy-authorization",
|
|
35
|
+
"x-auth-token",
|
|
36
|
+
"x-access-token",
|
|
37
|
+
"aws_secret_access_key",
|
|
38
|
+
"awsSecretAccessKey",
|
|
39
|
+
"secretAccessKey"
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Extra names that only mean "secret" inside transport configuration, where
|
|
43
|
+
* short words like `key` or `signature` are credentials, not log fields.
|
|
44
|
+
*/
|
|
45
|
+
const TRANSPORT_CONFIG_SECRET_NAMES = [
|
|
46
|
+
"writeKey",
|
|
47
|
+
"apiSecret",
|
|
48
|
+
"connectionString",
|
|
49
|
+
"sessionToken",
|
|
50
|
+
"passphrase",
|
|
51
|
+
"signature",
|
|
52
|
+
"pwd",
|
|
53
|
+
"pfx",
|
|
54
|
+
"cert",
|
|
55
|
+
"key",
|
|
56
|
+
"auth"
|
|
57
|
+
];
|
|
58
|
+
/** Query-string parameters whose values are never logged. */
|
|
59
|
+
const DEFAULT_REDACT_QUERY_PARAMS = [
|
|
60
|
+
"token",
|
|
61
|
+
"access_token",
|
|
62
|
+
"refresh_token",
|
|
63
|
+
"code",
|
|
64
|
+
"password",
|
|
65
|
+
"secret",
|
|
66
|
+
"api_key",
|
|
67
|
+
"apikey",
|
|
68
|
+
"key",
|
|
69
|
+
"signature",
|
|
70
|
+
"sig",
|
|
71
|
+
"auth"
|
|
72
|
+
];
|
|
73
|
+
// src/transports/secret-config.ts
|
|
74
|
+
/**
|
|
75
|
+
* Keeps credentials out of serialized transport output and error text.
|
|
76
|
+
*
|
|
77
|
+
* `protectSecrets()` replaces each listed field with a non-enumerable accessor backed
|
|
78
|
+
* by a WeakMap, whether or not the field is assigned yet, so later assignments (a
|
|
79
|
+
* connection opened on first write, a refreshed token) stay hidden too. It also
|
|
80
|
+
* installs `toJSON()` and a Node inspect hook returning a redacted view: scalar
|
|
81
|
+
* fields stay for debugging, secret-looking keys become '[REDACTED]', URLs lose
|
|
82
|
+
* userinfo, query and fragment. No Node imports, so browser bundles can use it.
|
|
83
|
+
*/
|
|
84
|
+
const REDACTED = "[REDACTED]";
|
|
85
|
+
const INSPECT_CUSTOM = Symbol.for("nodejs.util.inspect.custom");
|
|
86
|
+
const MAX_DEPTH = 4;
|
|
87
|
+
const SCHEME_PREFIX = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
88
|
+
function normalizeName(name) {
|
|
89
|
+
return name.toLowerCase().replaceAll("-", "").replaceAll("_", "");
|
|
90
|
+
}
|
|
91
|
+
const SECRET_NAMES = [...SENSITIVE_KEY_NAMES, ...TRANSPORT_CONFIG_SECRET_NAMES].map(normalizeName);
|
|
92
|
+
new Set(DEFAULT_REDACT_QUERY_PARAMS.map(normalizeName));
|
|
93
|
+
/** Exact match for short names (`key`, `pfx`), suffix match for longer ones (`azureClientSecret`). */
|
|
94
|
+
function isSecretKey(key) {
|
|
95
|
+
const name = normalizeName(key);
|
|
96
|
+
return SECRET_NAMES.some((n) => name === n || n.length >= 5 && name.endsWith(n));
|
|
97
|
+
}
|
|
98
|
+
function isUrlKey(key) {
|
|
99
|
+
return /url|uri|endpoint|href/i.test(key);
|
|
100
|
+
}
|
|
101
|
+
function isPlainObject(value) {
|
|
102
|
+
const proto = Object.getPrototypeOf(value);
|
|
103
|
+
return proto === Object.prototype || proto === null;
|
|
104
|
+
}
|
|
105
|
+
/** Absolute URL: `scheme://host` only. Relative or unparseable: path kept, query and fragment cut. */
|
|
106
|
+
function redactUrl(raw) {
|
|
107
|
+
if (typeof raw !== "string") return `${raw.protocol}//${raw.host}`;
|
|
108
|
+
if (SCHEME_PREFIX.test(raw)) try {
|
|
109
|
+
const url = new URL(raw);
|
|
110
|
+
return `${url.protocol}//${url.host}`;
|
|
111
|
+
} catch {
|
|
112
|
+
return REDACTED;
|
|
113
|
+
}
|
|
114
|
+
return raw.split(/[?#]/, 1)[0] ?? "";
|
|
115
|
+
}
|
|
116
|
+
function redactHeaders(headers) {
|
|
117
|
+
if (!headers || typeof headers !== "object") return headers;
|
|
118
|
+
return Object.fromEntries(Object.keys(headers).map((name) => [name, REDACTED]));
|
|
119
|
+
}
|
|
120
|
+
/** Redacted deep copy of a config-like value. Never throws, never returns a secret. */
|
|
121
|
+
function redactConfig(value, depth = 0, key = "") {
|
|
122
|
+
var _value$constructor;
|
|
123
|
+
if (value === null || value === void 0) return value;
|
|
124
|
+
if (typeof value === "string") return SCHEME_PREFIX.test(value) || isUrlKey(key) ? redactUrl(value) : value;
|
|
125
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
126
|
+
if (typeof value === "function") return "[Function]";
|
|
127
|
+
if (typeof value !== "object") return "[Unserializable]";
|
|
128
|
+
if (typeof URL !== "undefined" && value instanceof URL) return redactUrl(value);
|
|
129
|
+
if (Array.isArray(value)) return depth >= MAX_DEPTH ? "[Array]" : value.map((v) => redactConfig(v, depth + 1, key));
|
|
130
|
+
if (!isPlainObject(value) || depth >= MAX_DEPTH) return `[${((_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name) ?? "Object"}]`;
|
|
131
|
+
const out = {};
|
|
132
|
+
for (const [name, inner] of Object.entries(value)) if (isSecretKey(name)) out[name] = inner === void 0 ? void 0 : REDACTED;
|
|
133
|
+
else if (name.toLowerCase() === "headers") out[name] = redactHeaders(inner);
|
|
134
|
+
else out[name] = redactConfig(inner, depth + 1, name);
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
const hiddenKeys = /* @__PURE__ */ new WeakMap();
|
|
138
|
+
const hiddenValues = /* @__PURE__ */ new WeakMap();
|
|
139
|
+
function viewOf(target) {
|
|
140
|
+
var _target$constructor;
|
|
141
|
+
const hidden = hiddenKeys.get(target) ?? /* @__PURE__ */ new Set();
|
|
142
|
+
const values = hiddenValues.get(target);
|
|
143
|
+
const view = { class: (_target$constructor = target.constructor) === null || _target$constructor === void 0 ? void 0 : _target$constructor.name };
|
|
144
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(target), ...hidden])) {
|
|
145
|
+
const inner = hidden.has(key) ? values === null || values === void 0 ? void 0 : values.get(key) : target[key];
|
|
146
|
+
if (isSecretKey(key)) view[key] = inner === void 0 ? void 0 : REDACTED;
|
|
147
|
+
else if (key.toLowerCase() === "headers") view[key] = redactHeaders(inner);
|
|
148
|
+
else if (inner !== null && typeof inner === "object" && !hidden.has(key) && !(inner instanceof URL)) view[key] = "[Object]";
|
|
149
|
+
else if (hidden.has(key) && typeof inner === "string" && !isUrlKey(key)) view[key] = REDACTED;
|
|
150
|
+
else view[key] = redactConfig(inner, 0, key);
|
|
151
|
+
}
|
|
152
|
+
return view;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Hides `keys` on `target` (assigned or not yet) and gives it a redacted `toJSON()` /
|
|
156
|
+
* inspect view. Fields stay readable and writable. Safe to call more than once.
|
|
157
|
+
* Throws when the target cannot carry the protection (frozen or sealed), instead of
|
|
158
|
+
* silently leaving the secret enumerable.
|
|
159
|
+
*/
|
|
160
|
+
function protectSecrets(target, keys) {
|
|
161
|
+
if (!Object.isExtensible(target)) {
|
|
162
|
+
var _target$constructor2;
|
|
163
|
+
throw new TypeError(`protectSecrets: ${((_target$constructor2 = target.constructor) === null || _target$constructor2 === void 0 ? void 0 : _target$constructor2.name) ?? "object"} is not extensible`);
|
|
164
|
+
}
|
|
165
|
+
let hidden = hiddenKeys.get(target);
|
|
166
|
+
let values = hiddenValues.get(target);
|
|
167
|
+
if (!hidden || !values) {
|
|
168
|
+
hidden = /* @__PURE__ */ new Set();
|
|
169
|
+
values = /* @__PURE__ */ new Map();
|
|
170
|
+
hiddenKeys.set(target, hidden);
|
|
171
|
+
hiddenValues.set(target, values);
|
|
172
|
+
const view = () => viewOf(target);
|
|
173
|
+
Object.defineProperty(target, "toJSON", {
|
|
174
|
+
value: view,
|
|
175
|
+
enumerable: false,
|
|
176
|
+
configurable: true
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(target, INSPECT_CUSTOM, {
|
|
179
|
+
value: view,
|
|
180
|
+
enumerable: false,
|
|
181
|
+
configurable: true
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const store = values;
|
|
185
|
+
for (const key of keys) {
|
|
186
|
+
if (hidden.has(key)) continue;
|
|
187
|
+
const desc = Object.getOwnPropertyDescriptor(target, key);
|
|
188
|
+
if (desc && !desc.configurable) throw new TypeError(`protectSecrets: "${key}" is not configurable`);
|
|
189
|
+
if (desc && "value" in desc) store.set(key, desc.value);
|
|
190
|
+
hidden.add(key);
|
|
191
|
+
Object.defineProperty(target, key, {
|
|
192
|
+
enumerable: false,
|
|
193
|
+
configurable: true,
|
|
194
|
+
get: () => store.get(key),
|
|
195
|
+
set: (next) => void store.set(key, next)
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// src/utils/internal-log.ts
|
|
200
|
+
/**
|
|
201
|
+
* Internal logging helpers for use within the logixia library itself.
|
|
202
|
+
*
|
|
203
|
+
* These functions write directly to stderr/stdout without going through
|
|
204
|
+
* LogixiaLogger — this avoids circular dependencies and ensures internal
|
|
205
|
+
* diagnostics still surface even when the logger is misconfigured.
|
|
206
|
+
*
|
|
207
|
+
* Library code must NEVER call console.log/warn/error directly. Use these
|
|
208
|
+
* helpers instead so that internal output can be silenced in tests by setting
|
|
209
|
+
* the LOGIXIA_SILENT_INTERNAL=1 environment variable.
|
|
210
|
+
*/
|
|
211
|
+
/**
|
|
212
|
+
* Read the silence flag on each call rather than caching it at import time, so
|
|
213
|
+
* setting LOGIXIA_SILENT_INTERNAL=1 AFTER the module is first imported (e.g. in
|
|
214
|
+
* a test setup file) still takes effect — the documented test-silencing
|
|
215
|
+
* behavior was previously unreliable because the value was frozen at load.
|
|
216
|
+
*/
|
|
217
|
+
function isSilent() {
|
|
218
|
+
var _process$env;
|
|
219
|
+
if (typeof process !== "undefined" && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.LOGIXIA_SILENT_INTERNAL) === "1") return true;
|
|
220
|
+
const flag = globalThis["LOGIXIA_SILENT_INTERNAL"];
|
|
221
|
+
return flag === "1" || flag === 1 || flag === true;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Write a line to stderr, falling back to the matching console method where
|
|
225
|
+
* `process` is unavailable (browsers, Cloudflare Workers, Deno without Node compat).
|
|
226
|
+
*/
|
|
227
|
+
function writeLine(method, line) {
|
|
228
|
+
var _process$stderr;
|
|
229
|
+
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`);
|
|
230
|
+
else if (typeof console !== "undefined" && typeof console[method] === "function") console[method](line);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Emit an internal debug/info message to stderr.
|
|
234
|
+
* Use for field-enable/disable notifications that a developer might want to see
|
|
235
|
+
* during development but should not appear in production log streams.
|
|
236
|
+
*/
|
|
237
|
+
function internalLog(message) {
|
|
238
|
+
if (!isSilent()) writeLine("log", `[logixia] ${message}`);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Emit an internal warning to stderr.
|
|
242
|
+
* Use when something is misconfigured but logixia can continue operating.
|
|
243
|
+
*/
|
|
244
|
+
function internalWarn(message) {
|
|
245
|
+
if (!isSilent()) writeLine("warn", `[logixia:warn] ${message}`);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Emit an internal error to stderr.
|
|
249
|
+
* Use when a transport write fails or a serious internal error occurs.
|
|
250
|
+
*/
|
|
251
|
+
function internalError(message, error) {
|
|
252
|
+
if (!isSilent()) {
|
|
253
|
+
let errStr = "";
|
|
254
|
+
if (error instanceof Error) errStr = ` — ${error.message}`;
|
|
255
|
+
else if (error != null) errStr = ` — ${String(error)}`;
|
|
256
|
+
writeLine("error", `[logixia:error] ${message}${errStr}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// src/utils/safe-stringify.ts
|
|
9
260
|
/** Build a JSONPath like `$["a"][0]["b"]` for a decycle pointer. */
|
|
10
261
|
function jsonPath(parts) {
|
|
11
262
|
let path = "$";
|
|
@@ -89,9 +340,7 @@ function stringifyForLog(value) {
|
|
|
89
340
|
}
|
|
90
341
|
}
|
|
91
342
|
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/utils/otel.ts
|
|
343
|
+
// src/utils/otel.ts
|
|
95
344
|
let _otelApi;
|
|
96
345
|
function tryLoadOtelApi() {
|
|
97
346
|
if (_otelApi !== void 0) return _otelApi;
|
|
@@ -155,7 +404,6 @@ function getOtelMetaFields(opts = {}) {
|
|
|
155
404
|
[traceFlagsField]: ctx.traceFlags
|
|
156
405
|
};
|
|
157
406
|
}
|
|
158
|
-
let _bridgeOptions = null;
|
|
159
407
|
/**
|
|
160
408
|
* Initialise the global OTel bridge.
|
|
161
409
|
*
|
|
@@ -169,48 +417,59 @@ let _bridgeOptions = null;
|
|
|
169
417
|
* initOtelBridge();
|
|
170
418
|
* ```
|
|
171
419
|
*/
|
|
172
|
-
function initOtelBridge(opts = {}) {
|
|
173
|
-
_bridgeOptions = opts;
|
|
174
|
-
}
|
|
420
|
+
function initOtelBridge(opts = {}) {}
|
|
175
421
|
/**
|
|
176
422
|
* Disable the OTel bridge (useful for tests).
|
|
177
423
|
*/
|
|
178
|
-
function disableOtelBridge() {
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/utils/internal-log.ts
|
|
424
|
+
function disableOtelBridge() {}
|
|
425
|
+
// src/utils/typed-logger.ts
|
|
184
426
|
/**
|
|
185
|
-
*
|
|
427
|
+
* logixia — TypeScript typed log fields
|
|
186
428
|
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* diagnostics still surface even when the logger is misconfigured.
|
|
429
|
+
* Solves the type-safety gap: standard `Record<string, unknown>` metadata gives
|
|
430
|
+
* zero IDE autocomplete and lets typos slip silently into production logs.
|
|
190
431
|
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
*
|
|
432
|
+
* Two complementary utilities:
|
|
433
|
+
*
|
|
434
|
+
* 1. `createTypedLogger<TFields>()` — wraps any IBaseLogger so that the second
|
|
435
|
+
* argument of every log method is constrained to `TFields` (a typed object).
|
|
436
|
+
* Compile-time safety, zero runtime overhead.
|
|
437
|
+
*
|
|
438
|
+
* 2. `defineLogSchema<TFields>(schema)` — declares expected fields with optional
|
|
439
|
+
* validators. In development (NODE_ENV !== 'production') every log call is
|
|
440
|
+
* validated against the schema and a warning is emitted for missing required
|
|
441
|
+
* fields or type mismatches.
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```ts
|
|
445
|
+
* import { createTypedLogger, defineLogSchema } from 'logixia';
|
|
446
|
+
*
|
|
447
|
+
* interface OrderFields {
|
|
448
|
+
* orderId: string;
|
|
449
|
+
* userId: string;
|
|
450
|
+
* amount?: number;
|
|
451
|
+
* currency?: string;
|
|
452
|
+
* }
|
|
453
|
+
*
|
|
454
|
+
* const schema = defineLogSchema<OrderFields>({
|
|
455
|
+
* orderId: { type: 'string', required: true },
|
|
456
|
+
* userId: { type: 'string', required: true },
|
|
457
|
+
* amount: { type: 'number' },
|
|
458
|
+
* currency: { type: 'string' },
|
|
459
|
+
* });
|
|
460
|
+
*
|
|
461
|
+
* const orderLogger = createTypedLogger<OrderFields>(baseLogger, schema);
|
|
462
|
+
* await orderLogger.info('Order created', { orderId: 'ord_123', userId: 'usr_456', amount: 99.99 });
|
|
463
|
+
* // ^^^^ fully typed autocomplete ^^^^
|
|
464
|
+
* ```
|
|
207
465
|
*/
|
|
208
|
-
function
|
|
209
|
-
|
|
466
|
+
function isProduction() {
|
|
467
|
+
try {
|
|
468
|
+
return process.env.NODE_ENV === "production";
|
|
469
|
+
} catch {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
210
472
|
}
|
|
211
|
-
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/utils/typed-logger.ts
|
|
214
473
|
/**
|
|
215
474
|
* Define a typed schema for a category of log entries.
|
|
216
475
|
*
|
|
@@ -221,7 +480,7 @@ function defineLogSchema(fields) {
|
|
|
221
480
|
return {
|
|
222
481
|
fields,
|
|
223
482
|
validate(payload) {
|
|
224
|
-
if (
|
|
483
|
+
if (isProduction()) return [];
|
|
225
484
|
const warnings = [];
|
|
226
485
|
for (const [key, def] of Object.entries(fields)) {
|
|
227
486
|
const value = payload[key];
|
|
@@ -273,9 +532,42 @@ function createTypedLogger(logger, schema) {
|
|
|
273
532
|
trace: (m, d) => withValidation("trace", (logger.trace ?? logger.debug).bind(logger), m, d)
|
|
274
533
|
};
|
|
275
534
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
535
|
+
// src/browser.ts
|
|
536
|
+
/**
|
|
537
|
+
* logixia — Browser / Edge Runtime entry point
|
|
538
|
+
*
|
|
539
|
+
* This module is the browser-safe subset of logixia. It contains **no**
|
|
540
|
+
* references to Node.js built-ins (`node:fs`, `node:http`, `node:worker_threads`,
|
|
541
|
+
* `node:crypto`, `node:async_hooks`) so it can be bundled for:
|
|
542
|
+
*
|
|
543
|
+
* - Browser (Webpack / Vite / esbuild)
|
|
544
|
+
* - Cloudflare Workers / Vercel Edge Functions
|
|
545
|
+
* - Deno (via ESM import)
|
|
546
|
+
* - Bun (core subset, no file/DB transports)
|
|
547
|
+
*
|
|
548
|
+
* Excluded from this entry: FileTransport, DatabaseTransport, WorkerTransport,
|
|
549
|
+
* CloudWatchTransport, GCPTransport, AzureMonitorTransport, and anything that
|
|
550
|
+
* requires `AsyncLocalStorage`.
|
|
551
|
+
*
|
|
552
|
+
* @example Basic browser usage
|
|
553
|
+
* ```ts
|
|
554
|
+
* import { createBrowserLogger, BrowserConsoleTransport } from 'logixia/browser';
|
|
555
|
+
*
|
|
556
|
+
* const logger = createBrowserLogger({ appName: 'my-app' });
|
|
557
|
+
* logger.info('Page loaded', { url: location.href });
|
|
558
|
+
* ```
|
|
559
|
+
*
|
|
560
|
+
* @example Custom transport in browser
|
|
561
|
+
* ```ts
|
|
562
|
+
* import { createBrowserLogger, BrowserConsoleTransport } from 'logixia/browser';
|
|
563
|
+
*
|
|
564
|
+
* const logger = createBrowserLogger({
|
|
565
|
+
* appName: 'my-app',
|
|
566
|
+
* json: false, // pretty-print in devtools
|
|
567
|
+
* level: 'debug',
|
|
568
|
+
* });
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
279
571
|
const LEVEL_ORDER = {
|
|
280
572
|
verbose: 0,
|
|
281
573
|
debug: 1,
|
|
@@ -370,7 +662,7 @@ function validateRemoteUrl(raw) {
|
|
|
370
662
|
try {
|
|
371
663
|
parsed = new URL(raw);
|
|
372
664
|
} catch {
|
|
373
|
-
throw new TypeError(`BrowserRemoteTransport: invalid url
|
|
665
|
+
throw new TypeError(`BrowserRemoteTransport: invalid url [redacted]`);
|
|
374
666
|
}
|
|
375
667
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`BrowserRemoteTransport: url scheme "${parsed.protocol}" is not allowed; use http: or https:`);
|
|
376
668
|
return raw;
|
|
@@ -383,8 +675,33 @@ function validateRemoteUrl(raw) {
|
|
|
383
675
|
function byteLength(s) {
|
|
384
676
|
return new TextEncoder().encode(s).length;
|
|
385
677
|
}
|
|
678
|
+
const FAILURE_REPORT_INTERVAL_MS = 6e4;
|
|
679
|
+
/**
|
|
680
|
+
* Error name/code, HTTP status and host only. The error message is never
|
|
681
|
+
* included: runtimes embed request URLs (absolute or relative) and header
|
|
682
|
+
* values in it.
|
|
683
|
+
*/
|
|
684
|
+
function describeFailure(error, url) {
|
|
685
|
+
let host = "relative endpoint";
|
|
686
|
+
try {
|
|
687
|
+
host = `host ${new URL(url).host}`;
|
|
688
|
+
} catch {}
|
|
689
|
+
const e = error;
|
|
690
|
+
const parts = [];
|
|
691
|
+
if (e && typeof e.name === "string") parts.push(e.name);
|
|
692
|
+
if (e && typeof e.code === "string") parts.push(e.code);
|
|
693
|
+
if (e && typeof e.status === "number") parts.push(`HTTP ${e.status}`);
|
|
694
|
+
parts.push(host);
|
|
695
|
+
return parts.join(" ");
|
|
696
|
+
}
|
|
697
|
+
/** True only in a real browser page, where console noise reaches end users. */
|
|
698
|
+
function isBrowserPage() {
|
|
699
|
+
const g = globalThis;
|
|
700
|
+
return typeof g["window"] !== "undefined" && typeof g["document"] !== "undefined";
|
|
701
|
+
}
|
|
386
702
|
function isKeepaliveError(error) {
|
|
387
|
-
|
|
703
|
+
const message = error === null || error === void 0 ? void 0 : error.message;
|
|
704
|
+
return typeof message === "string" && /keepalive/i.test(message);
|
|
388
705
|
}
|
|
389
706
|
/**
|
|
390
707
|
* Browser transport that batches log entries and sends them to a remote
|
|
@@ -411,12 +728,17 @@ var BrowserRemoteTransport = class {
|
|
|
411
728
|
this.failedFlushCount = 0;
|
|
412
729
|
this.timer = null;
|
|
413
730
|
this.droppedEntries = 0;
|
|
731
|
+
this.reporting = false;
|
|
732
|
+
this.failureReported = false;
|
|
733
|
+
this.silent = options.silent ?? isBrowserPage();
|
|
734
|
+
this.onError = options.onError;
|
|
414
735
|
this.url = validateRemoteUrl(options.url);
|
|
415
736
|
this.headers = options.headers ?? {};
|
|
416
737
|
this.batchSize = options.batchSize ?? 100;
|
|
417
738
|
this.flushIntervalMs = options.flushIntervalMs ?? 5e3;
|
|
418
739
|
this.maxBufferSize = options.maxBufferSize ?? 1e3;
|
|
419
740
|
if (options.level !== void 0) this.level = options.level;
|
|
741
|
+
protectSecrets(this, ["headers", "url"]);
|
|
420
742
|
this.scheduleFlush();
|
|
421
743
|
}
|
|
422
744
|
/**
|
|
@@ -427,15 +749,23 @@ var BrowserRemoteTransport = class {
|
|
|
427
749
|
get dropped() {
|
|
428
750
|
return this.droppedEntries;
|
|
429
751
|
}
|
|
430
|
-
/** Number of flush attempts that failed
|
|
752
|
+
/** Number of flush attempts that failed (network error or non-OK HTTP status). */
|
|
431
753
|
get failedFlushes() {
|
|
432
754
|
return this.failedFlushCount;
|
|
433
755
|
}
|
|
434
|
-
/**
|
|
756
|
+
/**
|
|
757
|
+
* The most recent failure from a flush, if any: the raw fetch error (which on
|
|
758
|
+
* some runtimes embeds the request URL, so do not log it blindly) or an
|
|
759
|
+
* `Error` carrying only the HTTP status.
|
|
760
|
+
*/
|
|
435
761
|
get lastError() {
|
|
436
762
|
return this.lastFlushError;
|
|
437
763
|
}
|
|
438
764
|
write(entry) {
|
|
765
|
+
if (this.reporting) {
|
|
766
|
+
this.droppedEntries += 1;
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
439
769
|
this.batch.push(entry);
|
|
440
770
|
while (this.batch.length > this.maxBufferSize) {
|
|
441
771
|
this.batch.shift();
|
|
@@ -466,10 +796,15 @@ var BrowserRemoteTransport = class {
|
|
|
466
796
|
}
|
|
467
797
|
}
|
|
468
798
|
if (!res.ok) {
|
|
469
|
-
|
|
470
|
-
|
|
799
|
+
const failure = Object.assign(/* @__PURE__ */ new Error(`HTTP ${res.status}`), { status: res.status });
|
|
800
|
+
if (res.status >= 500 || res.status === 429) this.recordFailure(entries, failure);
|
|
801
|
+
else {
|
|
802
|
+
this.droppedEntries += entries.length;
|
|
803
|
+
this.recordFailure([], failure);
|
|
804
|
+
}
|
|
471
805
|
return;
|
|
472
806
|
}
|
|
807
|
+
this.reportRecovery();
|
|
473
808
|
}
|
|
474
809
|
}
|
|
475
810
|
send(body, keepalive) {
|
|
@@ -487,6 +822,34 @@ var BrowserRemoteTransport = class {
|
|
|
487
822
|
this.batch.unshift(...entries);
|
|
488
823
|
this.failedFlushCount += 1;
|
|
489
824
|
this.lastFlushError = error;
|
|
825
|
+
const now = Date.now();
|
|
826
|
+
const shouldReport = this.lastReportAt === void 0 || now - this.lastReportAt >= FAILURE_REPORT_INTERVAL_MS;
|
|
827
|
+
this.guarded(() => {
|
|
828
|
+
if (this.onError) try {
|
|
829
|
+
this.onError(error);
|
|
830
|
+
} catch {}
|
|
831
|
+
if (shouldReport && !this.silent) {
|
|
832
|
+
this.lastReportAt = now;
|
|
833
|
+
this.failureReported = true;
|
|
834
|
+
internalError(`BrowserRemoteTransport flush failed (${describeFailure(error, this.url)})`);
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
reportRecovery() {
|
|
839
|
+
if (!this.failureReported) return;
|
|
840
|
+
this.failureReported = false;
|
|
841
|
+
const now = Date.now();
|
|
842
|
+
if (this.lastRecoveryAt !== void 0 && now - this.lastRecoveryAt < FAILURE_REPORT_INTERVAL_MS) return;
|
|
843
|
+
this.lastRecoveryAt = now;
|
|
844
|
+
this.guarded(() => internalLog("BrowserRemoteTransport delivery recovered"));
|
|
845
|
+
}
|
|
846
|
+
guarded(fn) {
|
|
847
|
+
this.reporting = true;
|
|
848
|
+
try {
|
|
849
|
+
fn();
|
|
850
|
+
} finally {
|
|
851
|
+
this.reporting = false;
|
|
852
|
+
}
|
|
490
853
|
}
|
|
491
854
|
scheduleFlush() {
|
|
492
855
|
if (this.flushIntervalMs <= 0) return;
|
|
@@ -523,7 +886,10 @@ var BrowserLogger = class BrowserLogger {
|
|
|
523
886
|
context: config.context
|
|
524
887
|
};
|
|
525
888
|
if (config.silent) this.transports = [];
|
|
526
|
-
else
|
|
889
|
+
else {
|
|
890
|
+
const builtIn = new BrowserConsoleTransport({ json: this.config.json });
|
|
891
|
+
this.transports = [builtIn, ...config.transports ?? []];
|
|
892
|
+
}
|
|
527
893
|
}
|
|
528
894
|
verbose(message, payload) {
|
|
529
895
|
this.emit("verbose", message, payload);
|
|
@@ -611,7 +977,6 @@ function createBrowserLogger(config) {
|
|
|
611
977
|
* ```
|
|
612
978
|
*/
|
|
613
979
|
const browserLogger = new BrowserLogger({ appName: "App" });
|
|
614
|
-
|
|
615
|
-
//#endregion
|
|
616
980
|
export { BrowserConsoleTransport, BrowserLogger, BrowserRemoteTransport, browserLogger, createBrowserLogger, createTypedLogger, defineLogSchema, disableOtelBridge, getActiveOtelContext, getOtelMetaFields, initOtelBridge };
|
|
981
|
+
|
|
617
982
|
//# sourceMappingURL=browser.mjs.map
|