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
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// src/utils/sensitive-names.ts
|
|
2
|
+
/**
|
|
3
|
+
* The one list of sensitive names. Log redaction (redact.utils), the HTTP logger
|
|
4
|
+
* middleware and transport secret handling (transports/secret-config) all read it,
|
|
5
|
+
* so the lists cannot drift. No imports: safe from any module, including browser code.
|
|
6
|
+
*/
|
|
7
|
+
/** Field names redacted by name, wherever they appear in logged data. */
|
|
8
|
+
const SENSITIVE_KEY_NAMES = [
|
|
9
|
+
"password",
|
|
10
|
+
"passwd",
|
|
11
|
+
"secret",
|
|
12
|
+
"token",
|
|
13
|
+
"apiKey",
|
|
14
|
+
"api_key",
|
|
15
|
+
"accessToken",
|
|
16
|
+
"access_token",
|
|
17
|
+
"refreshToken",
|
|
18
|
+
"refresh_token",
|
|
19
|
+
"authorization",
|
|
20
|
+
"credentials",
|
|
21
|
+
"privateKey",
|
|
22
|
+
"private_key",
|
|
23
|
+
"clientSecret",
|
|
24
|
+
"client_secret",
|
|
25
|
+
"cookie",
|
|
26
|
+
"set-cookie",
|
|
27
|
+
"x-api-key",
|
|
28
|
+
"session",
|
|
29
|
+
"proxy-authorization",
|
|
30
|
+
"x-auth-token",
|
|
31
|
+
"x-access-token",
|
|
32
|
+
"aws_secret_access_key",
|
|
33
|
+
"awsSecretAccessKey",
|
|
34
|
+
"secretAccessKey"
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Extra names that only mean "secret" inside transport configuration, where
|
|
38
|
+
* short words like `key` or `signature` are credentials, not log fields.
|
|
39
|
+
*/
|
|
40
|
+
const TRANSPORT_CONFIG_SECRET_NAMES = [
|
|
41
|
+
"writeKey",
|
|
42
|
+
"apiSecret",
|
|
43
|
+
"connectionString",
|
|
44
|
+
"sessionToken",
|
|
45
|
+
"passphrase",
|
|
46
|
+
"signature",
|
|
47
|
+
"pwd",
|
|
48
|
+
"pfx",
|
|
49
|
+
"cert",
|
|
50
|
+
"key",
|
|
51
|
+
"auth"
|
|
52
|
+
];
|
|
53
|
+
/** Request headers whose values are never logged. */
|
|
54
|
+
const DEFAULT_REDACT_HEADERS = [
|
|
55
|
+
"authorization",
|
|
56
|
+
"cookie",
|
|
57
|
+
"set-cookie",
|
|
58
|
+
"x-api-key",
|
|
59
|
+
"proxy-authorization",
|
|
60
|
+
"x-auth-token",
|
|
61
|
+
"x-access-token",
|
|
62
|
+
"x-csrf-token",
|
|
63
|
+
"x-amz-security-token"
|
|
64
|
+
];
|
|
65
|
+
/** Query-string parameters whose values are never logged. */
|
|
66
|
+
const DEFAULT_REDACT_QUERY_PARAMS = [
|
|
67
|
+
"token",
|
|
68
|
+
"access_token",
|
|
69
|
+
"refresh_token",
|
|
70
|
+
"code",
|
|
71
|
+
"password",
|
|
72
|
+
"secret",
|
|
73
|
+
"api_key",
|
|
74
|
+
"apikey",
|
|
75
|
+
"key",
|
|
76
|
+
"signature",
|
|
77
|
+
"sig",
|
|
78
|
+
"auth"
|
|
79
|
+
];
|
|
80
|
+
// src/utils/internal-log.ts
|
|
81
|
+
/**
|
|
82
|
+
* Internal logging helpers for use within the logixia library itself.
|
|
83
|
+
*
|
|
84
|
+
* These functions write directly to stderr/stdout without going through
|
|
85
|
+
* LogixiaLogger — this avoids circular dependencies and ensures internal
|
|
86
|
+
* diagnostics still surface even when the logger is misconfigured.
|
|
87
|
+
*
|
|
88
|
+
* Library code must NEVER call console.log/warn/error directly. Use these
|
|
89
|
+
* helpers instead so that internal output can be silenced in tests by setting
|
|
90
|
+
* the LOGIXIA_SILENT_INTERNAL=1 environment variable.
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Read the silence flag on each call rather than caching it at import time, so
|
|
94
|
+
* setting LOGIXIA_SILENT_INTERNAL=1 AFTER the module is first imported (e.g. in
|
|
95
|
+
* a test setup file) still takes effect — the documented test-silencing
|
|
96
|
+
* behavior was previously unreliable because the value was frozen at load.
|
|
97
|
+
*/
|
|
98
|
+
function isSilent() {
|
|
99
|
+
var _process$env;
|
|
100
|
+
if (typeof process !== "undefined" && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.LOGIXIA_SILENT_INTERNAL) === "1") return true;
|
|
101
|
+
const flag = globalThis["LOGIXIA_SILENT_INTERNAL"];
|
|
102
|
+
return flag === "1" || flag === 1 || flag === true;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Write a line to stderr, falling back to the matching console method where
|
|
106
|
+
* `process` is unavailable (browsers, Cloudflare Workers, Deno without Node compat).
|
|
107
|
+
*/
|
|
108
|
+
function writeLine(method, line) {
|
|
109
|
+
var _process$stderr;
|
|
110
|
+
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`);
|
|
111
|
+
else if (typeof console !== "undefined" && typeof console[method] === "function") console[method](line);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Emit an internal debug/info message to stderr.
|
|
115
|
+
* Use for field-enable/disable notifications that a developer might want to see
|
|
116
|
+
* during development but should not appear in production log streams.
|
|
117
|
+
*/
|
|
118
|
+
function internalLog(message) {
|
|
119
|
+
if (!isSilent()) writeLine("log", `[logixia] ${message}`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Emit an internal warning to stderr.
|
|
123
|
+
* Use when something is misconfigured but logixia can continue operating.
|
|
124
|
+
*/
|
|
125
|
+
function internalWarn(message) {
|
|
126
|
+
if (!isSilent()) writeLine("warn", `[logixia:warn] ${message}`);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Emit an internal error to stderr.
|
|
130
|
+
* Use when a transport write fails or a serious internal error occurs.
|
|
131
|
+
*/
|
|
132
|
+
function internalError(message, error) {
|
|
133
|
+
if (!isSilent()) {
|
|
134
|
+
let errStr = "";
|
|
135
|
+
if (error instanceof Error) errStr = ` — ${error.message}`;
|
|
136
|
+
else if (error != null) errStr = ` — ${String(error)}`;
|
|
137
|
+
writeLine("error", `[logixia:error] ${message}${errStr}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export { DEFAULT_REDACT_QUERY_PARAMS as a, DEFAULT_REDACT_HEADERS as i, internalLog as n, SENSITIVE_KEY_NAMES as o, internalWarn as r, TRANSPORT_CONFIG_SECRET_NAMES as s, internalError as t };
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=internal-log-uCSd1PMc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-log-uCSd1PMc.mjs","names":[],"sources":["../src/utils/sensitive-names.ts","../src/utils/internal-log.ts"],"sourcesContent":["/**\n * The one list of sensitive names. Log redaction (redact.utils), the HTTP logger\n * middleware and transport secret handling (transports/secret-config) all read it,\n * so the lists cannot drift. No imports: safe from any module, including browser code.\n */\n\n/** Field names redacted by name, wherever they appear in logged data. */\nexport const SENSITIVE_KEY_NAMES: readonly string[] = [\n 'password',\n 'passwd',\n 'secret',\n 'token',\n 'apiKey',\n 'api_key',\n 'accessToken',\n 'access_token',\n 'refreshToken',\n 'refresh_token',\n 'authorization',\n 'credentials',\n 'privateKey',\n 'private_key',\n 'clientSecret',\n 'client_secret',\n 'cookie',\n 'set-cookie',\n 'x-api-key',\n 'session',\n 'proxy-authorization',\n 'x-auth-token',\n 'x-access-token',\n 'aws_secret_access_key',\n 'awsSecretAccessKey',\n 'secretAccessKey',\n];\n\n/**\n * Extra names that only mean \"secret\" inside transport configuration, where\n * short words like `key` or `signature` are credentials, not log fields.\n */\nexport const TRANSPORT_CONFIG_SECRET_NAMES: readonly string[] = [\n 'writeKey',\n 'apiSecret',\n 'connectionString',\n 'sessionToken',\n 'passphrase',\n 'signature',\n 'pwd',\n 'pfx',\n 'cert',\n 'key',\n 'auth',\n];\n\n/** Request headers whose values are never logged. */\nexport const DEFAULT_REDACT_HEADERS: readonly string[] = [\n 'authorization',\n 'cookie',\n 'set-cookie',\n 'x-api-key',\n 'proxy-authorization',\n 'x-auth-token',\n 'x-access-token',\n 'x-csrf-token',\n 'x-amz-security-token',\n];\n\n/** Query-string parameters whose values are never logged. */\nexport const DEFAULT_REDACT_QUERY_PARAMS: readonly string[] = [\n 'token',\n 'access_token',\n 'refresh_token',\n 'code',\n 'password',\n 'secret',\n 'api_key',\n 'apikey',\n 'key',\n 'signature',\n 'sig',\n 'auth',\n];\n","/**\n * Internal logging helpers for use within the logixia library itself.\n *\n * These functions write directly to stderr/stdout without going through\n * LogixiaLogger — this avoids circular dependencies and ensures internal\n * diagnostics still surface even when the logger is misconfigured.\n *\n * Library code must NEVER call console.log/warn/error directly. Use these\n * helpers instead so that internal output can be silenced in tests by setting\n * the LOGIXIA_SILENT_INTERNAL=1 environment variable.\n */\n\n/**\n * Read the silence flag on each call rather than caching it at import time, so\n * setting LOGIXIA_SILENT_INTERNAL=1 AFTER the module is first imported (e.g. in\n * a test setup file) still takes effect — the documented test-silencing\n * behavior was previously unreliable because the value was frozen at load.\n */\nfunction isSilent(): boolean {\n if (typeof process !== 'undefined' && process.env?.LOGIXIA_SILENT_INTERNAL === '1') return true;\n const flag = (globalThis as Record<string, unknown>)['LOGIXIA_SILENT_INTERNAL'];\n return flag === '1' || flag === 1 || flag === true;\n}\n\ntype ConsoleMethod = 'log' | 'warn' | 'error';\n\n/**\n * Write a line to stderr, falling back to the matching console method where\n * `process` is unavailable (browsers, Cloudflare Workers, Deno without Node compat).\n */\nfunction writeLine(method: ConsoleMethod, line: string): void {\n if (typeof process !== 'undefined' && typeof process.stderr?.write === 'function') {\n process.stderr.write(`${line}\\n`);\n } else if (typeof console !== 'undefined' && typeof console[method] === 'function') {\n console[method](line);\n }\n}\n\n/**\n * Emit an internal debug/info message to stderr.\n * Use for field-enable/disable notifications that a developer might want to see\n * during development but should not appear in production log streams.\n */\nexport function internalLog(message: string): void {\n if (!isSilent()) {\n writeLine('log', `[logixia] ${message}`);\n }\n}\n\n/**\n * Emit an internal warning to stderr.\n * Use when something is misconfigured but logixia can continue operating.\n */\nexport function internalWarn(message: string): void {\n if (!isSilent()) {\n writeLine('warn', `[logixia:warn] ${message}`);\n }\n}\n\n/**\n * Emit an internal error to stderr.\n * Use when a transport write fails or a serious internal error occurs.\n */\nexport function internalError(message: string, error?: unknown): void {\n if (!isSilent()) {\n let errStr = '';\n if (error instanceof Error) {\n errStr = ` — ${error.message}`;\n } else if (error != null) {\n errStr = ` — ${String(error)}`;\n }\n writeLine('error', `[logixia:error] ${message}${errStr}`);\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAa,sBAAyC;CACpD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAa,gCAAmD;CAC9D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,yBAA4C;CACvD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,8BAAiD;CAC5D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;AC/DA,SAAS,WAAoB;;CAC3B,IAAI,OAAO,YAAY,iBAAA,eAAe,QAAQ,SAAA,QAAA,iBAAA,KAAA,IAAA,KAAA,IAAA,aAAK,6BAA4B,KAAK,OAAO;CAC3F,MAAM,OAAQ,WAAuC;CACrD,OAAO,SAAS,OAAO,SAAS,KAAK,SAAS;AAChD;;;;;AAQA,SAAS,UAAU,QAAuB,MAAoB;;CAC5D,IAAI,OAAO,YAAY,eAAe,SAAA,kBAAO,QAAQ,YAAA,QAAA,oBAAA,KAAA,IAAA,KAAA,IAAA,gBAAQ,WAAU,YACrE,QAAQ,OAAO,MAAM,GAAG,KAAK,GAAG;MAC3B,IAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,YAAY,YACtE,QAAQ,OAAO,CAAC,IAAI;AAExB;;;;;;AAOA,SAAgB,YAAY,SAAuB;CACjD,IAAI,CAAC,SAAS,GACZ,UAAU,OAAO,aAAa,SAAS;AAE3C;;;;;AAMA,SAAgB,aAAa,SAAuB;CAClD,IAAI,CAAC,SAAS,GACZ,UAAU,QAAQ,kBAAkB,SAAS;AAEjD;;;;;AAMA,SAAgB,cAAc,SAAiB,OAAuB;CACpE,IAAI,CAAC,SAAS,GAAG;EACf,IAAI,SAAS;EACb,IAAI,iBAAiB,OACnB,SAAS,MAAM,MAAM;OAChB,IAAI,SAAS,MAClB,SAAS,MAAM,OAAO,KAAK;EAE7B,UAAU,SAAS,mBAAmB,UAAU,QAAQ;CAC1D;AACF"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { b as LoggerWithLevels, f as ILogger, h as LogEntry, p as ILoggerDefault, v as LogLevelString, x as NamespaceLevels, y as LoggerConfig } from "./index-DwozbmB4.js";
|
|
2
|
+
interface LogixiaPlugin {
|
|
3
|
+
/**
|
|
4
|
+
* Unique plugin name.
|
|
5
|
+
* logixia uses this to prevent duplicate registration of the same plugin
|
|
6
|
+
* on the same logger instance.
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* Called once immediately after `logger.use(plugin)` is called.
|
|
11
|
+
* Use for one-time setup (open connections, allocate buffers, etc.).
|
|
12
|
+
* Async `onInit` errors are silently swallowed to avoid blocking the logger.
|
|
13
|
+
*/
|
|
14
|
+
onInit?(): void | Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Called for every log entry **after** PII redaction and **before** transport
|
|
17
|
+
* dispatch. Plugins run in registration order; each receives the (possibly
|
|
18
|
+
* modified) output of the previous plugin.
|
|
19
|
+
*
|
|
20
|
+
* - Return the entry (modified or unchanged) to continue processing.
|
|
21
|
+
* - Return `null` to **drop** the entry — no transport will receive it.
|
|
22
|
+
*
|
|
23
|
+
* Errors thrown inside `onLog` are swallowed so a buggy plugin cannot crash
|
|
24
|
+
* logging; the chain continues with the previous (un-transformed) entry.
|
|
25
|
+
*/
|
|
26
|
+
onLog?(entry: LogEntry): LogEntry | null | Promise<LogEntry | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Called when a transport write fails (after any configured retries).
|
|
29
|
+
* Useful for routing transport errors to an alerting or metrics system.
|
|
30
|
+
* Errors thrown inside `onError` are silently swallowed.
|
|
31
|
+
*/
|
|
32
|
+
onError?(error: Error, entry?: LogEntry): void | Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Called when the logger is closed via `logger.close()` or the process
|
|
35
|
+
* receives a shutdown signal (when `gracefulShutdown` is enabled).
|
|
36
|
+
* Errors thrown inside `onShutdown` are silently swallowed.
|
|
37
|
+
*/
|
|
38
|
+
onShutdown?(): void | Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Holds an ordered list of `LogixiaPlugin` instances and dispatches lifecycle
|
|
42
|
+
* events to them. One registry is created per logger instance; a global
|
|
43
|
+
* singleton is also exported for process-wide registration.
|
|
44
|
+
*/
|
|
45
|
+
declare class PluginRegistry {
|
|
46
|
+
private readonly _plugins;
|
|
47
|
+
/**
|
|
48
|
+
* Register a plugin. Silently skips if a plugin with the same `name` is
|
|
49
|
+
* already registered on this registry.
|
|
50
|
+
*/
|
|
51
|
+
register(plugin: LogixiaPlugin): void;
|
|
52
|
+
/** Remove a previously registered plugin by name. No-op if not found. */
|
|
53
|
+
unregister(name: string): void;
|
|
54
|
+
/** Returns `true` if a plugin with the given name is registered. */
|
|
55
|
+
has(name: string): boolean;
|
|
56
|
+
/** Number of currently registered plugins. */
|
|
57
|
+
get size(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Run all `onLog` hooks in order.
|
|
60
|
+
* Returns `null` if any plugin cancels the entry; otherwise returns the
|
|
61
|
+
* (possibly transformed) entry.
|
|
62
|
+
*/
|
|
63
|
+
runOnLog(entry: LogEntry): Promise<LogEntry | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Notify all `onError` hooks.
|
|
66
|
+
* Errors thrown inside hooks are swallowed to prevent error cascades.
|
|
67
|
+
*/
|
|
68
|
+
runOnError(error: Error, entry?: LogEntry): Promise<void>;
|
|
69
|
+
/** Run all `onShutdown` hooks concurrently. Hook errors are swallowed. */
|
|
70
|
+
runOnShutdown(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Module-level singleton registry.
|
|
74
|
+
*
|
|
75
|
+
* Plugins registered here are automatically copied into every **new** logger
|
|
76
|
+
* instance created after the registration. Already-created loggers are not
|
|
77
|
+
* retroactively affected — use `logger.use(plugin)` for per-instance control.
|
|
78
|
+
*/
|
|
79
|
+
declare const globalPluginRegistry: PluginRegistry;
|
|
80
|
+
/**
|
|
81
|
+
* Register a plugin in the global registry so it applies to every future
|
|
82
|
+
* logger instance.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { usePlugin } from 'logixia';
|
|
87
|
+
*
|
|
88
|
+
* usePlugin({
|
|
89
|
+
* name: 'audit-sink',
|
|
90
|
+
* onLog(entry) {
|
|
91
|
+
* if (entry.level === 'error') auditQueue.push(entry);
|
|
92
|
+
* return entry;
|
|
93
|
+
* },
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
declare function usePlugin(plugin: LogixiaPlugin): void;
|
|
98
|
+
/**
|
|
99
|
+
* The logixia logger. Create instances with {@link createLogger} so that custom
|
|
100
|
+
* levels from `levelOptions.levels` also become methods.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const logger = createLogger({ appName: 'api', environment: 'production' });
|
|
105
|
+
* await logger.info('Server started', { port: 3000 });
|
|
106
|
+
* const req = logger.child('RequestHandler', { requestId: 'r-1' });
|
|
107
|
+
* await req.error(new Error('boom'));
|
|
108
|
+
* await logger.close(); // flush buffered transports before exit
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>> = LoggerConfig> implements ILoggerDefault {
|
|
112
|
+
[K: string]: any;
|
|
113
|
+
private config;
|
|
114
|
+
private context?;
|
|
115
|
+
private timers;
|
|
116
|
+
private contextData;
|
|
117
|
+
private transportManager;
|
|
118
|
+
private fieldState;
|
|
119
|
+
/** Stable fallback trace ID generated ONCE per logger instance. */
|
|
120
|
+
private readonly fallbackTraceId;
|
|
121
|
+
/** Numeric value for each known log level — built once, read on every log call. */
|
|
122
|
+
private _levelValues;
|
|
123
|
+
/** Numeric threshold for the currently active log level. */
|
|
124
|
+
private _minLevelValue;
|
|
125
|
+
/** Level set via setLevel(); outranks every other level source until the process ends. */
|
|
126
|
+
private _runtimeLevel;
|
|
127
|
+
/** `source=value` pairs already reported as unknown levels — warn once per logger. */
|
|
128
|
+
private readonly _warnedInvalidLevels;
|
|
129
|
+
/** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
|
|
130
|
+
private _colorMap;
|
|
131
|
+
/** Pre-computed field-enabled booleans so isFieldEnabled() isn't called per log. */
|
|
132
|
+
private _fieldCache;
|
|
133
|
+
/** True when contextData is non-empty — avoids Object.keys() check on hot path. */
|
|
134
|
+
private _hasContextData;
|
|
135
|
+
/**
|
|
136
|
+
* Pre-computed `[INFO] `, `[WARN] ` etc. strings — avoids a colorize() call per log.
|
|
137
|
+
* Key: lowercase level name. Value: formatted bracket string ready to concatenate.
|
|
138
|
+
*/
|
|
139
|
+
private _formattedLevels;
|
|
140
|
+
/** Pre-computed `[appName] ` string — avoids template literal allocation per log. */
|
|
141
|
+
private _formattedAppName;
|
|
142
|
+
/** True when a redact config is present — short-circuits applyRedaction when false. */
|
|
143
|
+
private _hasRedact;
|
|
144
|
+
/** Sampling engine — only created when sampling config is present. */
|
|
145
|
+
private _sampler;
|
|
146
|
+
/** Per-instance plugin registry — also inherits from the global registry at creation time. */
|
|
147
|
+
private readonly _pluginRegistry;
|
|
148
|
+
/** Set on loggers created by child(); they borrow the root's transports, sampler and plugins. */
|
|
149
|
+
private readonly _parent;
|
|
150
|
+
constructor(config: TConfig, context?: string, parent?: LogixiaLogger<TConfig>);
|
|
151
|
+
private setupGracefulShutdown;
|
|
152
|
+
private createCustomLevelMethods;
|
|
153
|
+
/**
|
|
154
|
+
* Rebuild all hot-path caches after any config mutation or level change.
|
|
155
|
+
* Keeps the actual log() call free of allocations in the common case.
|
|
156
|
+
*/
|
|
157
|
+
private _buildPerfCaches;
|
|
158
|
+
/**
|
|
159
|
+
* Log at `error` level. An `Error` is logged with its message and serialized
|
|
160
|
+
* (name, message, stack) under `data.error`; a string is logged as-is.
|
|
161
|
+
* `data` is merged into the entry payload.
|
|
162
|
+
*/
|
|
163
|
+
error(messageOrError: string | Error, data?: Record<string, unknown>): Promise<void>;
|
|
164
|
+
/** Log `message` at `warn` level; `data` is merged into the entry payload. */
|
|
165
|
+
warn(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
166
|
+
/** Log `message` at `info` level; `data` is merged into the entry payload. */
|
|
167
|
+
info(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
168
|
+
/** Log `message` at `debug` level; `data` is merged into the entry payload. */
|
|
169
|
+
debug(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
170
|
+
/** Log `message` at `trace` level; `data` is merged into the entry payload. */
|
|
171
|
+
trace(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
172
|
+
/** Log `message` at `verbose` level; `data` is merged into the entry payload. */
|
|
173
|
+
verbose(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Log at an arbitrary level name, including custom levels. Levels below the
|
|
176
|
+
* active threshold are dropped, as are level names that are not registered
|
|
177
|
+
* in `levelOptions.levels` (and are not built-in).
|
|
178
|
+
*/
|
|
179
|
+
logLevel(level: string, message: string, data?: Record<string, unknown>): Promise<void>;
|
|
180
|
+
/** Start a named timer; finish it with {@link timeEnd}. Reusing a label restarts it. */
|
|
181
|
+
time(label: string): void;
|
|
182
|
+
/**
|
|
183
|
+
* Stop the timer `label`, log its duration at `info` level, and return the
|
|
184
|
+
* elapsed milliseconds. Logs a `warn` and returns `undefined` if the timer
|
|
185
|
+
* does not exist.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* logger.time('db');
|
|
190
|
+
* await query();
|
|
191
|
+
* const ms = await logger.timeEnd('db');
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
timeEnd(label: string): Promise<number | undefined>;
|
|
195
|
+
timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
|
|
196
|
+
/**
|
|
197
|
+
* Change the minimum log level at runtime. The override outranks
|
|
198
|
+
* `LOGIXIA_LEVEL`, `LOGIXIA_LEVEL_<NS>` and `namespaceLevels`, and survives
|
|
199
|
+
* later changes to fields or namespace levels. Unknown level names are
|
|
200
|
+
* ignored with a warning and the current level is kept.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* logger.setLevel('debug');
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
setLevel(level: LogLevelString): void;
|
|
208
|
+
/**
|
|
209
|
+
* Return the configured minimum log level, not the per-namespace effective
|
|
210
|
+
* one. Without `setLevel()` it is `LOGIXIA_LEVEL`, else `levelOptions.level`,
|
|
211
|
+
* else a `NODE_ENV` default (`debug` in development, `warn` in test), else `info`.
|
|
212
|
+
*/
|
|
213
|
+
getLevel(): LogLevelString;
|
|
214
|
+
private _validLevelList;
|
|
215
|
+
/**
|
|
216
|
+
* Canonicalise a level from config/ENV. Unknown values return undefined so the
|
|
217
|
+
* caller falls through to the next source, and warn once per logger per source.
|
|
218
|
+
*/
|
|
219
|
+
private _validLevel;
|
|
220
|
+
/**
|
|
221
|
+
* Replace the per-namespace level map at runtime — no restart needed.
|
|
222
|
+
*
|
|
223
|
+
* This is the runtime counterpart to the `namespaceLevels` config option and
|
|
224
|
+
* the most-requested logging feature across the Winston/Pino issue trackers
|
|
225
|
+
* (flip a module's verbosity live to chase a bug without raising global
|
|
226
|
+
* volume). The new map fully replaces the previous one.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* // Turn on debug for the DB layer only, live:
|
|
231
|
+
* logger.setNamespaceLevels({ 'db.*': 'debug', '*': 'info' });
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
setNamespaceLevels(levels: NamespaceLevels): void;
|
|
235
|
+
/** Merge entries into the existing per-namespace level map at runtime. */
|
|
236
|
+
patchNamespaceLevels(levels: NamespaceLevels): void;
|
|
237
|
+
/** Return a copy of the current per-namespace level map. */
|
|
238
|
+
getNamespaceLevels(): NamespaceLevels;
|
|
239
|
+
/** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
|
|
240
|
+
setContext(context: string): void;
|
|
241
|
+
/** Return the current context label, or `undefined` if none is set. */
|
|
242
|
+
getContext(): string | undefined;
|
|
243
|
+
/** Show `fieldName` in log output, overriding the config for this logger instance. */
|
|
244
|
+
enableField(fieldName: string): void;
|
|
245
|
+
/** Hide `fieldName` from log output, overriding the config for this logger instance. */
|
|
246
|
+
disableField(fieldName: string): void;
|
|
247
|
+
/** Whether `fieldName` is currently shown: runtime override first, then config, default `true`. */
|
|
248
|
+
isFieldEnabled(fieldName: string): boolean;
|
|
249
|
+
/** Return the visibility (`true` = shown) of every standard log field. */
|
|
250
|
+
getFieldState(): Record<string, boolean>;
|
|
251
|
+
/** Drop all runtime enable/disable overrides so field visibility follows the config again. */
|
|
252
|
+
resetFieldState(): void;
|
|
253
|
+
/** @deprecated No-op. Library code never prompts on stdin; use setTransportLevels(). */
|
|
254
|
+
enableTransportLevelPrompting(): void;
|
|
255
|
+
/** @deprecated No-op. */
|
|
256
|
+
disableTransportLevelPrompting(): void;
|
|
257
|
+
/** Restrict `transportId` to only the given `levels`. Warns if no transports are configured. */
|
|
258
|
+
setTransportLevels(transportId: string, levels: string[]): void;
|
|
259
|
+
/** Return the levels `transportId` is restricted to, or `undefined` if it has none. */
|
|
260
|
+
getTransportLevels(transportId: string): string[] | undefined;
|
|
261
|
+
clearTransportLevelPreferences(): void;
|
|
262
|
+
/** Return the identifiers of the configured transports (empty if none). */
|
|
263
|
+
getAvailableTransports(): string[];
|
|
264
|
+
/**
|
|
265
|
+
* Create a child logger with its own `context` that shares this logger's
|
|
266
|
+
* configuration and transports. `data` is merged into the bound fields
|
|
267
|
+
* inherited from this logger and added to every entry the child writes.
|
|
268
|
+
* Closing a child does not close the shared transports.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const req = logger.child('Checkout', { requestId: 'r-42' });
|
|
273
|
+
* await req.info('started'); // entry includes requestId
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
child(context: string, data?: Record<string, unknown>): ILogger;
|
|
277
|
+
/**
|
|
278
|
+
* Register a plugin on this logger instance.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* logger.use({
|
|
283
|
+
* name: 'audit',
|
|
284
|
+
* onLog(entry) { auditQueue.push(entry); return entry; },
|
|
285
|
+
* });
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
use(plugin: LogixiaPlugin): this;
|
|
289
|
+
/**
|
|
290
|
+
* Remove a previously registered plugin by name.
|
|
291
|
+
* No-op if the plugin is not registered on this instance.
|
|
292
|
+
*/
|
|
293
|
+
unuse(pluginName: string): this;
|
|
294
|
+
/** Flush buffered entries in all transports without closing them. */
|
|
295
|
+
flush(): Promise<void>;
|
|
296
|
+
/** Report whether the transports are healthy; `healthy: false` if no transport manager exists. */
|
|
297
|
+
healthCheck(): Promise<{
|
|
298
|
+
healthy: boolean;
|
|
299
|
+
details: Record<string, unknown>;
|
|
300
|
+
}>;
|
|
301
|
+
/**
|
|
302
|
+
* Warn about timers that were never ended, then flush and close all transports,
|
|
303
|
+
* stop the sampler and run plugin shutdown hooks. On a child logger only the
|
|
304
|
+
* timer warnings run; the shared transports stay open.
|
|
305
|
+
*
|
|
306
|
+
* To flush on SIGTERM/SIGINT, set the `gracefulShutdown` config option rather
|
|
307
|
+
* than writing your own signal handler; do not combine it with a manual
|
|
308
|
+
* handler that calls `process.exit`, which can cut the flush short.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* await logger.close(); // e.g. at the end of a script or a test
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
close(): Promise<void>;
|
|
316
|
+
private log;
|
|
317
|
+
/**
|
|
318
|
+
* Hot-path level check: a single Map lookup + integer compare.
|
|
319
|
+
* The level map and threshold are pre-built in _buildPerfCaches().
|
|
320
|
+
*/
|
|
321
|
+
private shouldLog;
|
|
322
|
+
/**
|
|
323
|
+
* Feature 3: Resolve the effective log level for this logger instance.
|
|
324
|
+
*
|
|
325
|
+
* Priority:
|
|
326
|
+
* 0. A level set at runtime with `setLevel()` (explicit programmatic call, wins over all below)
|
|
327
|
+
* 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
|
|
328
|
+
* 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
|
|
329
|
+
* 3. Global `LOGIXIA_LEVEL` ENV override
|
|
330
|
+
* 4. `levelOptions.level` (resolved via Feature 5 in constructor)
|
|
331
|
+
*/
|
|
332
|
+
private resolveEffectiveLevel;
|
|
333
|
+
private formatLog;
|
|
334
|
+
private colorize;
|
|
335
|
+
/**
|
|
336
|
+
* Dispatch the entry to transports (each formats itself). Returns `void` when
|
|
337
|
+
* the write completes synchronously (console-only hot path) and a Promise only
|
|
338
|
+
* when a transport is genuinely async — so the caller awaits only when needed.
|
|
339
|
+
* Formatting for the no-transport fallback is done lazily, never on the
|
|
340
|
+
* transport path.
|
|
341
|
+
*/
|
|
342
|
+
private output;
|
|
343
|
+
/** Shared transport-failure handler: log internally, notify plugins, then fall
|
|
344
|
+
* back to a direct stdout/stderr write so the entry is never lost. */
|
|
345
|
+
private _handleOutputError;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Create a logger from `config`, with an optional default `context` label.
|
|
349
|
+
*
|
|
350
|
+
* Every key of `levelOptions.levels` that is not already a method becomes an
|
|
351
|
+
* async method on the returned logger, typed through the config, and routes to
|
|
352
|
+
* {@link LogixiaLogger.logLevel}.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```ts
|
|
356
|
+
* const logger = createLogger({
|
|
357
|
+
* appName: 'api',
|
|
358
|
+
* levelOptions: { level: 'info', levels: { error: 0, warn: 1, info: 2, audit: 2 } },
|
|
359
|
+
* });
|
|
360
|
+
* await logger.audit('user exported data', { userId: 'u1' });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
declare function createLogger<T extends LoggerConfig<Record<string, number>>>(config: T, context?: string): LoggerWithLevels<T>;
|
|
364
|
+
export { globalPluginRegistry as a, PluginRegistry as i, createLogger as n, usePlugin as o, LogixiaPlugin as r, LogixiaLogger as t };
|
|
365
|
+
//# sourceMappingURL=logitron-logger-D2B75Oc7.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logitron-logger-D2B75Oc7.d.ts","names":[],"sources":["../src/plugin.ts","../src/core/logitron-logger.ts"],"mappings":";UAkCiB;;;;;;EAMf;;;;;;EAOA,kBAAkB;;;;;;;;;;;;EAalB,OAAO,OAAO,WAAW,kBAAkB,QAAQ;;;;;;EAOnD,SAAS,OAAO,OAAO,QAAQ,kBAAkB;;;;;;EAOjD,sBAAsB;;;;;;;cAUX;mBACM;;;;;EAMjB,SAAS,QAAQ;;EAiBjB,WAAW;;EAMX,IAAI;;MAKA;;;;;;EASE,SAAS,OAAO,WAAW,QAAQ;;;;;EAsBnC,WAAW,OAAO,OAAO,QAAQ,WAAW;;EAiB5C,iBAAiB;;;;;;;;;cA2BZ,sBAAoB;;;;;;;;;;;;;;;;;;iBAmBjB,UAAU,QAAQ;;;;;;;;;;;;;;cC7BrB,cACX,gBAAgB,aAAa,0BAA0B,yBAC5C;GAEV;UAEO;UACA;UACA;UACA;UACA;UACA;;mBAGS;;UAIT;;UAEA;;UAEA;;mBAES;;UAET;;UAEA;;UAEA;;;;;UAKA;;UAEA;;UAEA;;UAEA;;mBAES;;mBAEA;EAEL,YAAA,QAAQ,SAAS,kBAAkB,SAAS,cAAc;UAqG9D;UAiBA;;;;;UAqBA;;;;;;EA2HF,MAAM,yBAAyB,OAAO,OAAO,0BAA0B;;EAYvE,KAAK,iBAAiB,OAAO,0BAA0B;;EAKvD,KAAK,iBAAiB,OAAO,0BAA0B;;EAKvD,MAAM,iBAAiB,OAAO,0BAA0B;;EAKxD,MAAM,iBAAiB,OAAO,0BAA0B;;EAKxD,QAAQ,iBAAiB,OAAO,0BAA0B;;;;;;EAS1D,SAAS,eAAe,iBAAiB,OAAO,0BAA0B;;EAOhF,KAAK;;;;;;;;;;;;;EAgBC,QAAQ,gBAAgB;EAmBxB,UAAU,GAAG,eAAe,UAAU,QAAQ,KAAK,QAAQ;;;;;;;;;;;;EAyBjE,SAAS,OAAO;;;;;;EAuBhB,YAAY;UAIJ;;;;;UAQA;;;;;;;;;;;;;;;EA8BR,mBAAmB,QAAQ;;EAQ3B,qBAAqB,QAAQ;;EAM7B,sBAAsB;;EAKtB,WAAW;;EAKX;;EAOA,YAAY;;EASZ,aAAa;;EASb,eAAe;;EASf,iBAAiB;;EAmBjB;;EAQA;;EAMA;;EAMA,mBAAmB,qBAAqB;;EAMxC,mBAAmB;EAMnB;;EAMA;;;;;;;;;;;;;EAkBA,MAAM,iBAAiB,OAAO,0BAA0B;;;;;;;;;;;;EA0BxD,IAAI,QAAQ;;;;;EASZ,MAAM;;EAQA,SAAS;;EAKT,eAAe;IAAU;IAAkB,SAAS;;;;;;;;;;;;;;;;EAqBpD,SAAS;UAsBD;;;;;UA0GN;;;;;;;;;;;UAeA;UAwCA;UAgDA;;;;;;;;UAcA;;;UAuBM;;;;;;;;;;;;;;;;;;iBA+BA,aAAa,UAAU,aAAa,yBAClD,QAAQ,GACR,mBACC,iBAAiB"}
|