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
|
@@ -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"}
|
|
@@ -1,7 +1,4 @@
|
|
|
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-
|
|
2
|
-
|
|
3
|
-
//#region src/plugin.d.ts
|
|
4
|
-
|
|
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";
|
|
5
2
|
interface LogixiaPlugin {
|
|
6
3
|
/**
|
|
7
4
|
* Unique plugin name.
|
|
@@ -98,8 +95,19 @@ declare const globalPluginRegistry: PluginRegistry;
|
|
|
98
95
|
* ```
|
|
99
96
|
*/
|
|
100
97
|
declare function usePlugin(plugin: LogixiaPlugin): void;
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
*/
|
|
103
111
|
declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>> = LoggerConfig> implements ILoggerDefault {
|
|
104
112
|
[K: string]: any;
|
|
105
113
|
private config;
|
|
@@ -114,6 +122,8 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
114
122
|
private _levelValues;
|
|
115
123
|
/** Numeric threshold for the currently active log level. */
|
|
116
124
|
private _minLevelValue;
|
|
125
|
+
/** Level set via setLevel(); outranks every other level source until the process ends. */
|
|
126
|
+
private _runtimeLevel;
|
|
117
127
|
/** `source=value` pairs already reported as unknown levels — warn once per logger. */
|
|
118
128
|
private readonly _warnedInvalidLevels;
|
|
119
129
|
/** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
|
|
@@ -145,17 +155,61 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
145
155
|
* Keeps the actual log() call free of allocations in the common case.
|
|
146
156
|
*/
|
|
147
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
|
+
*/
|
|
148
163
|
error(messageOrError: string | Error, data?: Record<string, unknown>): Promise<void>;
|
|
164
|
+
/** Log `message` at `warn` level; `data` is merged into the entry payload. */
|
|
149
165
|
warn(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
166
|
+
/** Log `message` at `info` level; `data` is merged into the entry payload. */
|
|
150
167
|
info(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
168
|
+
/** Log `message` at `debug` level; `data` is merged into the entry payload. */
|
|
151
169
|
debug(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
170
|
+
/** Log `message` at `trace` level; `data` is merged into the entry payload. */
|
|
152
171
|
trace(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
172
|
+
/** Log `message` at `verbose` level; `data` is merged into the entry payload. */
|
|
153
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
|
+
*/
|
|
154
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. */
|
|
155
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
|
+
*/
|
|
156
194
|
timeEnd(label: string): Promise<number | undefined>;
|
|
157
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
|
+
*/
|
|
158
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
|
+
*/
|
|
159
213
|
getLevel(): LogLevelString;
|
|
160
214
|
private _validLevelList;
|
|
161
215
|
/**
|
|
@@ -182,21 +236,43 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
182
236
|
patchNamespaceLevels(levels: NamespaceLevels): void;
|
|
183
237
|
/** Return a copy of the current per-namespace level map. */
|
|
184
238
|
getNamespaceLevels(): NamespaceLevels;
|
|
239
|
+
/** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
|
|
185
240
|
setContext(context: string): void;
|
|
241
|
+
/** Return the current context label, or `undefined` if none is set. */
|
|
186
242
|
getContext(): string | undefined;
|
|
243
|
+
/** Show `fieldName` in log output, overriding the config for this logger instance. */
|
|
187
244
|
enableField(fieldName: string): void;
|
|
245
|
+
/** Hide `fieldName` from log output, overriding the config for this logger instance. */
|
|
188
246
|
disableField(fieldName: string): void;
|
|
247
|
+
/** Whether `fieldName` is currently shown: runtime override first, then config, default `true`. */
|
|
189
248
|
isFieldEnabled(fieldName: string): boolean;
|
|
249
|
+
/** Return the visibility (`true` = shown) of every standard log field. */
|
|
190
250
|
getFieldState(): Record<string, boolean>;
|
|
251
|
+
/** Drop all runtime enable/disable overrides so field visibility follows the config again. */
|
|
191
252
|
resetFieldState(): void;
|
|
192
253
|
/** @deprecated No-op. Library code never prompts on stdin; use setTransportLevels(). */
|
|
193
254
|
enableTransportLevelPrompting(): void;
|
|
194
255
|
/** @deprecated No-op. */
|
|
195
256
|
disableTransportLevelPrompting(): void;
|
|
257
|
+
/** Restrict `transportId` to only the given `levels`. Warns if no transports are configured. */
|
|
196
258
|
setTransportLevels(transportId: string, levels: string[]): void;
|
|
259
|
+
/** Return the levels `transportId` is restricted to, or `undefined` if it has none. */
|
|
197
260
|
getTransportLevels(transportId: string): string[] | undefined;
|
|
198
261
|
clearTransportLevelPreferences(): void;
|
|
262
|
+
/** Return the identifiers of the configured transports (empty if none). */
|
|
199
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
|
+
*/
|
|
200
276
|
child(context: string, data?: Record<string, unknown>): ILogger;
|
|
201
277
|
/**
|
|
202
278
|
* Register a plugin on this logger instance.
|
|
@@ -215,11 +291,27 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
215
291
|
* No-op if the plugin is not registered on this instance.
|
|
216
292
|
*/
|
|
217
293
|
unuse(pluginName: string): this;
|
|
294
|
+
/** Flush buffered entries in all transports without closing them. */
|
|
218
295
|
flush(): Promise<void>;
|
|
296
|
+
/** Report whether the transports are healthy; `healthy: false` if no transport manager exists. */
|
|
219
297
|
healthCheck(): Promise<{
|
|
220
298
|
healthy: boolean;
|
|
221
299
|
details: Record<string, unknown>;
|
|
222
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
|
+
*/
|
|
223
315
|
close(): Promise<void>;
|
|
224
316
|
private log;
|
|
225
317
|
/**
|
|
@@ -231,6 +323,7 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
231
323
|
* Feature 3: Resolve the effective log level for this logger instance.
|
|
232
324
|
*
|
|
233
325
|
* Priority:
|
|
326
|
+
* 0. A level set at runtime with `setLevel()` (explicit programmatic call, wins over all below)
|
|
234
327
|
* 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
|
|
235
328
|
* 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
|
|
236
329
|
* 3. Global `LOGIXIA_LEVEL` ENV override
|
|
@@ -251,7 +344,22 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
251
344
|
* back to a direct stdout/stderr write so the entry is never lost. */
|
|
252
345
|
private _handleOutputError;
|
|
253
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
|
+
*/
|
|
254
363
|
declare function createLogger<T extends LoggerConfig<Record<string, number>>>(config: T, context?: string): LoggerWithLevels<T>;
|
|
255
|
-
//#endregion
|
|
256
364
|
export { globalPluginRegistry as a, PluginRegistry as i, createLogger as n, usePlugin as o, LogixiaPlugin as r, LogixiaLogger as t };
|
|
257
|
-
//# sourceMappingURL=logitron-logger-
|
|
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"}
|
|
@@ -1,7 +1,4 @@
|
|
|
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-
|
|
2
|
-
|
|
3
|
-
//#region src/plugin.d.ts
|
|
4
|
-
|
|
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-xqaJtAZn.mjs";
|
|
5
2
|
interface LogixiaPlugin {
|
|
6
3
|
/**
|
|
7
4
|
* Unique plugin name.
|
|
@@ -98,8 +95,19 @@ declare const globalPluginRegistry: PluginRegistry;
|
|
|
98
95
|
* ```
|
|
99
96
|
*/
|
|
100
97
|
declare function usePlugin(plugin: LogixiaPlugin): void;
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
*/
|
|
103
111
|
declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>> = LoggerConfig> implements ILoggerDefault {
|
|
104
112
|
[K: string]: any;
|
|
105
113
|
private config;
|
|
@@ -114,6 +122,8 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
114
122
|
private _levelValues;
|
|
115
123
|
/** Numeric threshold for the currently active log level. */
|
|
116
124
|
private _minLevelValue;
|
|
125
|
+
/** Level set via setLevel(); outranks every other level source until the process ends. */
|
|
126
|
+
private _runtimeLevel;
|
|
117
127
|
/** `source=value` pairs already reported as unknown levels — warn once per logger. */
|
|
118
128
|
private readonly _warnedInvalidLevels;
|
|
119
129
|
/** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
|
|
@@ -145,17 +155,61 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
145
155
|
* Keeps the actual log() call free of allocations in the common case.
|
|
146
156
|
*/
|
|
147
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
|
+
*/
|
|
148
163
|
error(messageOrError: string | Error, data?: Record<string, unknown>): Promise<void>;
|
|
164
|
+
/** Log `message` at `warn` level; `data` is merged into the entry payload. */
|
|
149
165
|
warn(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
166
|
+
/** Log `message` at `info` level; `data` is merged into the entry payload. */
|
|
150
167
|
info(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
168
|
+
/** Log `message` at `debug` level; `data` is merged into the entry payload. */
|
|
151
169
|
debug(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
170
|
+
/** Log `message` at `trace` level; `data` is merged into the entry payload. */
|
|
152
171
|
trace(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
172
|
+
/** Log `message` at `verbose` level; `data` is merged into the entry payload. */
|
|
153
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
|
+
*/
|
|
154
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. */
|
|
155
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
|
+
*/
|
|
156
194
|
timeEnd(label: string): Promise<number | undefined>;
|
|
157
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
|
+
*/
|
|
158
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
|
+
*/
|
|
159
213
|
getLevel(): LogLevelString;
|
|
160
214
|
private _validLevelList;
|
|
161
215
|
/**
|
|
@@ -182,21 +236,43 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
182
236
|
patchNamespaceLevels(levels: NamespaceLevels): void;
|
|
183
237
|
/** Return a copy of the current per-namespace level map. */
|
|
184
238
|
getNamespaceLevels(): NamespaceLevels;
|
|
239
|
+
/** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
|
|
185
240
|
setContext(context: string): void;
|
|
241
|
+
/** Return the current context label, or `undefined` if none is set. */
|
|
186
242
|
getContext(): string | undefined;
|
|
243
|
+
/** Show `fieldName` in log output, overriding the config for this logger instance. */
|
|
187
244
|
enableField(fieldName: string): void;
|
|
245
|
+
/** Hide `fieldName` from log output, overriding the config for this logger instance. */
|
|
188
246
|
disableField(fieldName: string): void;
|
|
247
|
+
/** Whether `fieldName` is currently shown: runtime override first, then config, default `true`. */
|
|
189
248
|
isFieldEnabled(fieldName: string): boolean;
|
|
249
|
+
/** Return the visibility (`true` = shown) of every standard log field. */
|
|
190
250
|
getFieldState(): Record<string, boolean>;
|
|
251
|
+
/** Drop all runtime enable/disable overrides so field visibility follows the config again. */
|
|
191
252
|
resetFieldState(): void;
|
|
192
253
|
/** @deprecated No-op. Library code never prompts on stdin; use setTransportLevels(). */
|
|
193
254
|
enableTransportLevelPrompting(): void;
|
|
194
255
|
/** @deprecated No-op. */
|
|
195
256
|
disableTransportLevelPrompting(): void;
|
|
257
|
+
/** Restrict `transportId` to only the given `levels`. Warns if no transports are configured. */
|
|
196
258
|
setTransportLevels(transportId: string, levels: string[]): void;
|
|
259
|
+
/** Return the levels `transportId` is restricted to, or `undefined` if it has none. */
|
|
197
260
|
getTransportLevels(transportId: string): string[] | undefined;
|
|
198
261
|
clearTransportLevelPreferences(): void;
|
|
262
|
+
/** Return the identifiers of the configured transports (empty if none). */
|
|
199
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
|
+
*/
|
|
200
276
|
child(context: string, data?: Record<string, unknown>): ILogger;
|
|
201
277
|
/**
|
|
202
278
|
* Register a plugin on this logger instance.
|
|
@@ -215,11 +291,27 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
215
291
|
* No-op if the plugin is not registered on this instance.
|
|
216
292
|
*/
|
|
217
293
|
unuse(pluginName: string): this;
|
|
294
|
+
/** Flush buffered entries in all transports without closing them. */
|
|
218
295
|
flush(): Promise<void>;
|
|
296
|
+
/** Report whether the transports are healthy; `healthy: false` if no transport manager exists. */
|
|
219
297
|
healthCheck(): Promise<{
|
|
220
298
|
healthy: boolean;
|
|
221
299
|
details: Record<string, unknown>;
|
|
222
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
|
+
*/
|
|
223
315
|
close(): Promise<void>;
|
|
224
316
|
private log;
|
|
225
317
|
/**
|
|
@@ -231,6 +323,7 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
231
323
|
* Feature 3: Resolve the effective log level for this logger instance.
|
|
232
324
|
*
|
|
233
325
|
* Priority:
|
|
326
|
+
* 0. A level set at runtime with `setLevel()` (explicit programmatic call, wins over all below)
|
|
234
327
|
* 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
|
|
235
328
|
* 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
|
|
236
329
|
* 3. Global `LOGIXIA_LEVEL` ENV override
|
|
@@ -251,7 +344,22 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>>
|
|
|
251
344
|
* back to a direct stdout/stderr write so the entry is never lost. */
|
|
252
345
|
private _handleOutputError;
|
|
253
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
|
+
*/
|
|
254
363
|
declare function createLogger<T extends LoggerConfig<Record<string, number>>>(config: T, context?: string): LoggerWithLevels<T>;
|
|
255
|
-
//#endregion
|
|
256
364
|
export { globalPluginRegistry as a, PluginRegistry as i, createLogger as n, usePlugin as o, LogixiaPlugin as r, LogixiaLogger as t };
|
|
257
|
-
//# sourceMappingURL=logitron-logger-
|
|
365
|
+
//# sourceMappingURL=logitron-logger-oEd6wNhf.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logitron-logger-oEd6wNhf.d.mts","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"}
|
package/dist/middleware.d.mts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { u as IBaseLogger } from "./index-3mw5gaCw.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/middleware/http-logger.d.ts
|
|
5
|
-
|
|
1
|
+
import { u as IBaseLogger } from "./index-xqaJtAZn.mjs";
|
|
6
2
|
interface HttpLoggerOptions {
|
|
7
3
|
/**
|
|
8
4
|
* Skip logging for a request. Called before any I/O.
|
|
@@ -28,10 +24,13 @@ interface HttpLoggerOptions {
|
|
|
28
24
|
*/
|
|
29
25
|
extraFields?: (req: IncomingRequest) => Record<string, unknown>;
|
|
30
26
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
27
|
+
* Header name, or list of names tried in order, to read the trace ID from.
|
|
28
|
+
* Default: the library-wide list (`DEFAULT_TRACE_HEADERS`: traceparent,
|
|
29
|
+
* x-trace-id, x-request-id, x-correlation-id, trace-id).
|
|
30
|
+
* If none is present, `request.id` is used when it is not a framework counter,
|
|
31
|
+
* otherwise a UUID is generated and shared with the logixia context helpers.
|
|
33
32
|
*/
|
|
34
|
-
traceIdHeader?: string;
|
|
33
|
+
traceIdHeader?: string | readonly string[];
|
|
35
34
|
/**
|
|
36
35
|
* Additional headers to redact from logged output. Merged with the defaults
|
|
37
36
|
* (authorization, cookie, set-cookie, x-api-key, proxy-authorization,
|
|
@@ -73,7 +72,7 @@ interface OutgoingResponse {
|
|
|
73
72
|
/**
|
|
74
73
|
* Create an Express / Connect compatible middleware that replaces Morgan.
|
|
75
74
|
*/
|
|
76
|
-
declare function createExpressMiddleware(logger: IBaseLogger, options?: HttpLoggerOptions): (req: IncomingRequest, res: OutgoingResponse, next: () => void) => void;
|
|
75
|
+
export declare function createExpressMiddleware(logger: IBaseLogger, options?: HttpLoggerOptions): (req: IncomingRequest, res: OutgoingResponse, next: () => void) => void;
|
|
77
76
|
interface FastifyInstance {
|
|
78
77
|
addHook: (name: string, fn: (req: unknown, reply: unknown, done: () => void) => void) => void;
|
|
79
78
|
}
|
|
@@ -85,9 +84,8 @@ interface FastifyInstance {
|
|
|
85
84
|
* await fastify.register(createFastifyPlugin(logger, { slowRequestThresholdMs: 500 }));
|
|
86
85
|
* ```
|
|
87
86
|
*/
|
|
88
|
-
declare function createFastifyPlugin(logger: IBaseLogger, options?: HttpLoggerOptions): ((fastify: FastifyInstance, _opts: unknown, done: () => void) => void) & {
|
|
87
|
+
export declare function createFastifyPlugin(logger: IBaseLogger, options?: HttpLoggerOptions): ((fastify: FastifyInstance, _opts: unknown, done: () => void) => void) & {
|
|
89
88
|
[x: symbol]: string | boolean;
|
|
90
89
|
};
|
|
91
|
-
|
|
92
|
-
export { type FastifyInstance, type HttpLoggerOptions, type IncomingRequest, type OutgoingResponse, createExpressMiddleware, createFastifyPlugin };
|
|
90
|
+
export type { FastifyInstance, HttpLoggerOptions, IncomingRequest, OutgoingResponse };
|
|
93
91
|
//# sourceMappingURL=middleware.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.mts","names":[],"sources":["../src/middleware/http-logger.ts"],"
|
|
1
|
+
{"version":3,"file":"middleware.d.mts","names":[],"sources":["../src/middleware/http-logger.ts"],"mappings":";UAgCiB;;;;;EAKf,QAAQ,KAAK;;;;;;EAMb;;EAEA;;;;;EAKA;;;;;EAKA,eAAe,KAAK,oBAAoB;;;;;;;;EAQxC;;;;;;EAMA;;;;;;EAMA;;;;;EAKA;;EAEA;;EAEA;;UAIe;EACf;EACA;EACA,UAAU;EACV;EACA;IAAW;;EACX;;UAGe;EACf;EACA,MAAM,eAAe;EACrB,QAAQ,eAAe;EACvB,aAAa;;;;;wBAkGC,wBACd,QAAQ,aACR,UAAS,qBACP,KAAK,iBAAiB,KAAK,kBAAkB;UAqFhC;EACf,UAAU,cAAc,KAAK,cAAc,gBAAgB;;;;;;;;;;wBAW7C,oBAAoB,QAAQ,aAAa,UAAS,sBAAsB,SAY/C,iBAAe,gBAAgB"}
|