logixia 2.0.11 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/{async-context-BGUCdYAa.mjs → async-context-1YMPGgJZ.mjs} +3 -3
- package/dist/{async-context-BGUCdYAa.mjs.map → async-context-1YMPGgJZ.mjs.map} +1 -1
- package/dist/{async-context-D8um9I5V.js → async-context-CoPhbRG0.js} +4 -4
- package/dist/{async-context-D8um9I5V.js.map → async-context-CoPhbRG0.js.map} +1 -1
- package/dist/{azure-monitor.transport-CTnfwA0F.mjs → azure-monitor.transport-B_dqSV_o.mjs} +4 -4
- package/dist/{azure-monitor.transport-CTnfwA0F.mjs.map → azure-monitor.transport-B_dqSV_o.mjs.map} +1 -1
- package/dist/{azure-monitor.transport-C8KdmsSw.js → azure-monitor.transport-Bl3xVvpN.js} +4 -4
- package/dist/{azure-monitor.transport-C8KdmsSw.js.map → azure-monitor.transport-Bl3xVvpN.js.map} +1 -1
- package/dist/{azure-monitor.transport-CbSHOnNX.d.mts → azure-monitor.transport-C5VjvREZ.d.mts} +2 -2
- package/dist/{azure-monitor.transport-CbSHOnNX.d.mts.map → azure-monitor.transport-C5VjvREZ.d.mts.map} +1 -1
- package/dist/{azure-monitor.transport-Bvf7Xegt.d.ts → azure-monitor.transport-CyHDjHS-.d.ts} +2 -2
- package/dist/{azure-monitor.transport-Bvf7Xegt.d.ts.map → azure-monitor.transport-CyHDjHS-.d.ts.map} +1 -1
- package/dist/azure.d.mts +1 -1
- package/dist/azure.d.ts +1 -1
- package/dist/azure.js +1 -1
- package/dist/azure.mjs +1 -1
- package/dist/{batch-buffer-BJqzpfpT.mjs → batch-buffer-BnmVCCwI.mjs} +2 -2
- package/dist/{batch-buffer-BJqzpfpT.mjs.map → batch-buffer-BnmVCCwI.mjs.map} +1 -1
- package/dist/{batch-buffer-BTQdAXwC.js → batch-buffer-C-ETEX3Y.js} +2 -2
- package/dist/{batch-buffer-BTQdAXwC.js.map → batch-buffer-C-ETEX3Y.js.map} +1 -1
- package/dist/browser.d.mts +2 -0
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +33 -15
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +33 -15
- package/dist/browser.mjs.map +1 -1
- package/dist/{builder-C6kKEVrU.mjs → builder-CbttbixM.mjs} +158 -279
- package/dist/builder-CbttbixM.mjs.map +1 -0
- package/dist/{builder-Up4YxX7l.js → builder-Ck1tsC5d.js} +160 -305
- package/dist/builder-Ck1tsC5d.js.map +1 -0
- package/dist/cloudwatch.d.mts +1 -1
- package/dist/cloudwatch.d.ts +1 -1
- package/dist/cloudwatch.js +1 -1
- package/dist/cloudwatch.mjs +1 -1
- package/dist/{cloudwatch.transport-Bl1qzdBx.mjs → cloudwatch.transport-Brh5fmRN.mjs} +5 -5
- package/dist/{cloudwatch.transport-Bl1qzdBx.mjs.map → cloudwatch.transport-Brh5fmRN.mjs.map} +1 -1
- package/dist/{cloudwatch.transport-BoCyxNKO.js → cloudwatch.transport-DO9e__Z-.js} +5 -5
- package/dist/{cloudwatch.transport-BoCyxNKO.js.map → cloudwatch.transport-DO9e__Z-.js.map} +1 -1
- package/dist/{cloudwatch.transport-CQyT6U91.d.ts → cloudwatch.transport-DdSjUWvu.d.ts} +2 -2
- package/dist/{cloudwatch.transport-CQyT6U91.d.ts.map → cloudwatch.transport-DdSjUWvu.d.ts.map} +1 -1
- package/dist/{cloudwatch.transport-CjVrI6S4.d.mts → cloudwatch.transport-_hS7Mcc5.d.mts} +2 -2
- package/dist/{cloudwatch.transport-CjVrI6S4.d.mts.map → cloudwatch.transport-_hS7Mcc5.d.mts.map} +1 -1
- package/dist/correlation.js +3 -3
- package/dist/correlation.mjs +3 -3
- package/dist/{entry-fields-CJbeaoBs.js → entry-fields-BSLkzw18.js} +3 -3
- package/dist/{entry-fields-CJbeaoBs.js.map → entry-fields-BSLkzw18.js.map} +1 -1
- package/dist/{entry-fields-D_aNnjg0.mjs → entry-fields-J1OBi24o.mjs} +2 -2
- package/dist/{entry-fields-D_aNnjg0.mjs.map → entry-fields-J1OBi24o.mjs.map} +1 -1
- package/dist/error.utils-B8_CwESF.mjs +189 -0
- package/dist/error.utils-B8_CwESF.mjs.map +1 -0
- package/dist/error.utils-fZkRExam.js +212 -0
- package/dist/error.utils-fZkRExam.js.map +1 -0
- package/dist/fastify.d.mts +89 -0
- package/dist/fastify.d.mts.map +1 -0
- package/dist/fastify.d.ts +89 -0
- package/dist/fastify.d.ts.map +1 -0
- package/dist/fastify.js +265 -0
- package/dist/fastify.js.map +1 -0
- package/dist/fastify.mjs +263 -0
- package/dist/fastify.mjs.map +1 -0
- package/dist/gcp.d.mts +1 -1
- package/dist/gcp.d.ts +1 -1
- package/dist/gcp.js +1 -1
- package/dist/gcp.mjs +1 -1
- package/dist/{gcp.transport-DOH4bpWM.mjs → gcp.transport-BY1Z3cS0.mjs} +5 -5
- package/dist/{gcp.transport-DOH4bpWM.mjs.map → gcp.transport-BY1Z3cS0.mjs.map} +1 -1
- package/dist/{gcp.transport-D9SdLPwP.d.mts → gcp.transport-C8VJiEM7.d.mts} +2 -2
- package/dist/{gcp.transport-D9SdLPwP.d.mts.map → gcp.transport-C8VJiEM7.d.mts.map} +1 -1
- package/dist/{gcp.transport-BCIvdFV-.d.ts → gcp.transport-Ct0BtKFo.d.ts} +2 -2
- package/dist/{gcp.transport-BCIvdFV-.d.ts.map → gcp.transport-Ct0BtKFo.d.ts.map} +1 -1
- package/dist/{gcp.transport-D_NHVZrw.js → gcp.transport-V9R4dwdT.js} +5 -5
- package/dist/{gcp.transport-D_NHVZrw.js.map → gcp.transport-V9R4dwdT.js.map} +1 -1
- package/dist/hono.d.mts +66 -0
- package/dist/hono.d.mts.map +1 -0
- package/dist/hono.d.ts +66 -0
- package/dist/hono.d.ts.map +1 -0
- package/dist/hono.js +512 -0
- package/dist/hono.js.map +1 -0
- package/dist/hono.mjs +511 -0
- package/dist/hono.mjs.map +1 -0
- package/dist/{index-BAkPHp5D.d.mts → index-B3ajtXJd.d.mts} +2 -2
- package/dist/{index-BAkPHp5D.d.mts.map → index-B3ajtXJd.d.mts.map} +1 -1
- package/dist/{index-e7LowmAu.d.ts → index-oqD3WNxf.d.ts} +2 -2
- package/dist/{index-e7LowmAu.d.ts.map → index-oqD3WNxf.d.ts.map} +1 -1
- package/dist/index.d.mts +8 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{logitron-logger-DVUdgmBY.d.ts → logitron-logger-Csn3e6Qu.d.ts} +2 -2
- package/dist/{logitron-logger-DVUdgmBY.d.ts.map → logitron-logger-Csn3e6Qu.d.ts.map} +1 -1
- package/dist/{logitron-logger-DoWmMjYB.d.mts → logitron-logger-fMOkXr8H.d.mts} +2 -2
- package/dist/{logitron-logger-DoWmMjYB.d.mts.map → logitron-logger-fMOkXr8H.d.mts.map} +1 -1
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +6 -5
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +4 -3
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +47 -15
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +47 -15
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +172 -50
- package/dist/nest.js.map +1 -1
- package/dist/nest.mjs +168 -46
- package/dist/nest.mjs.map +1 -1
- package/dist/{otel-DH6-G6DR.js → otel-BrgvxLDW.js} +319 -66
- package/dist/otel-BrgvxLDW.js.map +1 -0
- package/dist/{otel-DAVxpArV.mjs → otel-C5jBV_l_.mjs} +319 -66
- package/dist/otel-C5jBV_l_.mjs.map +1 -0
- package/dist/own-property-BWkibepN.js +40 -0
- package/dist/own-property-BWkibepN.js.map +1 -0
- package/dist/own-property-CjFw9qwZ.mjs +29 -0
- package/dist/own-property-CjFw9qwZ.mjs.map +1 -0
- package/dist/{request-trace-C7kXMjx5.js → request-trace-6NBSw5lt.js} +14 -3
- package/dist/{request-trace-C7kXMjx5.js.map → request-trace-6NBSw5lt.js.map} +1 -1
- package/dist/{request-trace-Dekcnenb.mjs → request-trace-txUhyyre.mjs} +9 -4
- package/dist/{request-trace-Dekcnenb.mjs.map → request-trace-txUhyyre.mjs.map} +1 -1
- package/dist/{safe-stringify-pZOnzGRJ.mjs → safe-stringify-B5p5ktFe.mjs} +2 -2
- package/dist/{safe-stringify-pZOnzGRJ.mjs.map → safe-stringify-B5p5ktFe.mjs.map} +1 -1
- package/dist/{safe-stringify-CJisLyZ3.js → safe-stringify-J3sh-7YM.js} +5 -5
- package/dist/{safe-stringify-CJisLyZ3.js.map → safe-stringify-J3sh-7YM.js.map} +1 -1
- package/dist/{search-Crf2IEoA.d.mts → search-B-hJe2N-.d.mts} +7 -3
- package/dist/{search-Crf2IEoA.d.mts.map → search-B-hJe2N-.d.mts.map} +1 -1
- package/dist/{search-B4eEzrhM.d.ts → search-BlKBLm5D.d.ts} +7 -3
- package/dist/{search-B4eEzrhM.d.ts.map → search-BlKBLm5D.d.ts.map} +1 -1
- package/dist/{search-CjYl-mo5.mjs → search-CTR4XNHq.mjs} +52 -14
- package/dist/search-CTR4XNHq.mjs.map +1 -0
- package/dist/{search-CJw_xoQl.js → search-_qx4YzRP.js} +52 -14
- package/dist/search-_qx4YzRP.js.map +1 -0
- package/dist/search.d.mts +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/search.js +1 -1
- package/dist/search.mjs +1 -1
- package/dist/{secret-config-D1F4MW69.mjs → secret-config-Cng7XPLx.mjs} +18 -13
- package/dist/secret-config-Cng7XPLx.mjs.map +1 -0
- package/dist/{secret-config-6hdODxBb.js → secret-config-OqmIPmpV.js} +21 -16
- package/dist/secret-config-OqmIPmpV.js.map +1 -0
- package/dist/{sensitive-names-wv27qBQC.mjs → sensitive-names-BiBM6R1X.mjs} +2 -28
- package/dist/sensitive-names-BiBM6R1X.mjs.map +1 -0
- package/dist/{sensitive-names-CNgHaqv9.js → sensitive-names-NiKIRhp5.js} +1 -39
- package/dist/sensitive-names-NiKIRhp5.js.map +1 -0
- package/dist/{slack.transport-C6E0l4kw.d.ts → slack.transport-5OPL7H3u.d.mts} +76 -3
- package/dist/slack.transport-5OPL7H3u.d.mts.map +1 -0
- package/dist/{slack.transport-BDyENuR0.d.mts → slack.transport-BFpBD_Ri.d.ts} +76 -3
- package/dist/slack.transport-BFpBD_Ri.d.ts.map +1 -0
- package/dist/{slack.transport-YvaLJxNv.mjs → slack.transport-C6dzPJHX.mjs} +226 -9
- package/dist/slack.transport-C6dzPJHX.mjs.map +1 -0
- package/dist/{slack.transport-CEYBVzUj.js → slack.transport-Ci0swStG.js} +231 -8
- package/dist/slack.transport-Ci0swStG.js.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{transport.types-CzJq4IrF.d.ts → transport.types-B1ejJJP6.d.mts} +6 -1
- package/dist/transport.types-B1ejJJP6.d.mts.map +1 -0
- package/dist/{transport.types-CzJq4IrF.d.mts → transport.types-B1ejJJP6.d.ts} +6 -1
- package/dist/transport.types-B1ejJJP6.d.ts.map +1 -0
- package/dist/transports.d.mts +61 -11
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +61 -11
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +7 -6
- package/dist/transports.mjs +7 -7
- package/dist/worker-entry.js +106 -22
- package/dist/worker.d.mts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.mjs +1 -1
- package/dist/{worker.transport-B9mCQSM1.d.ts → worker.transport-B7olL1Uh.d.ts} +12 -2
- package/dist/worker.transport-B7olL1Uh.d.ts.map +1 -0
- package/dist/{worker.transport-CwNpH98o.js → worker.transport-CZOutlxC.js} +40 -2
- package/dist/worker.transport-CZOutlxC.js.map +1 -0
- package/dist/{worker.transport-DgK_ZXlB.mjs → worker.transport-CxFD8mvS.mjs} +40 -2
- package/dist/worker.transport-CxFD8mvS.mjs.map +1 -0
- package/dist/{worker.transport-Bl8lFRck.d.mts → worker.transport-DnU0_9Bd.d.mts} +12 -2
- package/dist/worker.transport-DnU0_9Bd.d.mts.map +1 -0
- package/package.json +37 -2
- package/dist/builder-C6kKEVrU.mjs.map +0 -1
- package/dist/builder-Up4YxX7l.js.map +0 -1
- package/dist/otel-DAVxpArV.mjs.map +0 -1
- package/dist/otel-DH6-G6DR.js.map +0 -1
- package/dist/search-CJw_xoQl.js.map +0 -1
- package/dist/search-CjYl-mo5.mjs.map +0 -1
- package/dist/secret-config-6hdODxBb.js.map +0 -1
- package/dist/secret-config-D1F4MW69.mjs.map +0 -1
- package/dist/sensitive-names-CNgHaqv9.js.map +0 -1
- package/dist/sensitive-names-wv27qBQC.mjs.map +0 -1
- package/dist/slack.transport-BDyENuR0.d.mts.map +0 -1
- package/dist/slack.transport-C6E0l4kw.d.ts.map +0 -1
- package/dist/slack.transport-CEYBVzUj.js.map +0 -1
- package/dist/slack.transport-YvaLJxNv.mjs.map +0 -1
- package/dist/transport.types-CzJq4IrF.d.mts.map +0 -1
- package/dist/transport.types-CzJq4IrF.d.ts.map +0 -1
- package/dist/worker.transport-B9mCQSM1.d.ts.map +0 -1
- package/dist/worker.transport-Bl8lFRck.d.mts.map +0 -1
- package/dist/worker.transport-CwNpH98o.js.map +0 -1
- package/dist/worker.transport-DgK_ZXlB.mjs.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as LogixiaContext } from "./async-context-
|
|
4
|
-
import { n as
|
|
1
|
+
import { t as assignOwn } from "./own-property-CjFw9qwZ.mjs";
|
|
2
|
+
import { s as TraceContext } from "./request-trace-txUhyyre.mjs";
|
|
3
|
+
import { t as LogixiaContext } from "./async-context-1YMPGgJZ.mjs";
|
|
4
|
+
import { a as buildNameSet, n as DEFAULT_REDACT_QUERY_PARAMS, o as redactUrlQuery, r as SENSITIVE_KEY_NAMES, s as redactUrlsInText } from "./sensitive-names-BiBM6R1X.mjs";
|
|
5
|
+
import { n as protectSecrets } from "./secret-config-Cng7XPLx.mjs";
|
|
5
6
|
import { n as internalLog, r as internalWarn, t as internalError } from "./internal-log-Cy5nF1ZL.mjs";
|
|
7
|
+
import { i as stringifyForLog } from "./safe-stringify-B5p5ktFe.mjs";
|
|
6
8
|
import { n as safeToString } from "./csv.utils-ZdxSod5g.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { c as TransportManager, n as _getOtelPayloadIfEnabled, r as _isOtelBridgeEnabled, v as stripControlChars } from "./otel-C5jBV_l_.mjs";
|
|
10
|
+
import { i as serializeNestedErrors, r as serializeError, t as isError } from "./error.utils-B8_CwESF.mjs";
|
|
9
11
|
import { constants } from "node:os";
|
|
10
12
|
// src/types/index.ts
|
|
11
13
|
const LogLevel = {
|
|
@@ -179,191 +181,6 @@ const globalPluginRegistry = new PluginRegistry();
|
|
|
179
181
|
function usePlugin(plugin) {
|
|
180
182
|
globalPluginRegistry.register(plugin);
|
|
181
183
|
}
|
|
182
|
-
// src/utils/error.utils.ts
|
|
183
|
-
const EXTRA_FIELDS = [
|
|
184
|
-
"code",
|
|
185
|
-
"statusCode",
|
|
186
|
-
"status",
|
|
187
|
-
"errno",
|
|
188
|
-
"syscall",
|
|
189
|
-
"path",
|
|
190
|
-
"address",
|
|
191
|
-
"port",
|
|
192
|
-
"type"
|
|
193
|
-
];
|
|
194
|
-
const SKIPPED_FIELDS = /* @__PURE__ */ new Set([
|
|
195
|
-
"name",
|
|
196
|
-
"message",
|
|
197
|
-
"stack",
|
|
198
|
-
"cause",
|
|
199
|
-
"errors",
|
|
200
|
-
...EXTRA_FIELDS
|
|
201
|
-
]);
|
|
202
|
-
const NO_OPTIONS = Object.freeze({});
|
|
203
|
-
const NO_FIELDS = [];
|
|
204
|
-
/**
|
|
205
|
-
* Serialize an Error into a plain JSON-safe object, including:
|
|
206
|
-
* - `name`, `message`, `stack`
|
|
207
|
-
* - `cause` (recursively serialized, full ES2022 chain)
|
|
208
|
-
* - `errors` (for AggregateError)
|
|
209
|
-
* - standard Node.js error fields (`code`, `statusCode`, `errno`, …)
|
|
210
|
-
* - any other enumerable own properties
|
|
211
|
-
*/
|
|
212
|
-
function serializeError(error, options = NO_OPTIONS) {
|
|
213
|
-
const { includeStack = true, maxDepth = 5, excludeFields = NO_FIELDS } = options;
|
|
214
|
-
return _serializeError(error, includeStack, maxDepth, excludeFields, 0, /* @__PURE__ */ new WeakSet());
|
|
215
|
-
}
|
|
216
|
-
function _serializeError(error, includeStack, maxDepth, excludeFields, depth, seen) {
|
|
217
|
-
if (depth >= maxDepth) return {
|
|
218
|
-
name: error.name,
|
|
219
|
-
message: error.message,
|
|
220
|
-
_truncated: true
|
|
221
|
-
};
|
|
222
|
-
if (seen.has(error)) return {
|
|
223
|
-
name: error.name,
|
|
224
|
-
message: error.message,
|
|
225
|
-
_circular: true
|
|
226
|
-
};
|
|
227
|
-
seen.add(error);
|
|
228
|
-
const serialized = {
|
|
229
|
-
name: error.name,
|
|
230
|
-
message: error.message
|
|
231
|
-
};
|
|
232
|
-
if (includeStack && error.stack) serialized.stack = error.stack;
|
|
233
|
-
const errorWithCause = error;
|
|
234
|
-
if (errorWithCause.cause !== void 0) {
|
|
235
|
-
if (errorWithCause.cause instanceof Error) serialized.cause = _serializeError(errorWithCause.cause, includeStack, maxDepth, excludeFields, depth + 1, seen);
|
|
236
|
-
else serialized.cause = serializeValue(errorWithCause.cause, maxDepth - depth - 1, seen);
|
|
237
|
-
}
|
|
238
|
-
const aggregateError = error;
|
|
239
|
-
if (Array.isArray(aggregateError.errors)) serialized.errors = aggregateError.errors.map((e) => e instanceof Error ? _serializeError(e, includeStack, maxDepth, excludeFields, depth + 1, seen) : serializeValue(e, maxDepth - depth - 1, seen));
|
|
240
|
-
const errorRecord = error;
|
|
241
|
-
for (const field of EXTRA_FIELDS) if (!excludeFields.includes(field) && errorRecord[field] !== void 0) serialized[field] = errorRecord[field];
|
|
242
|
-
const skip = excludeFields.length === 0 ? SKIPPED_FIELDS : /* @__PURE__ */ new Set([...SKIPPED_FIELDS, ...excludeFields]);
|
|
243
|
-
for (const key of Object.getOwnPropertyNames(error)) {
|
|
244
|
-
if (skip.has(key)) continue;
|
|
245
|
-
try {
|
|
246
|
-
assignOwn(serialized, key, serializeValue(errorRecord[key], maxDepth - depth - 1, seen));
|
|
247
|
-
} catch {
|
|
248
|
-
assignOwn(serialized, key, "[Unserializable]");
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return serialized;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Recursively serialize an arbitrary value to a JSON-safe representation.
|
|
255
|
-
*
|
|
256
|
-
* The `seen` guard is threaded through (not recreated) so cross-referencing
|
|
257
|
-
* errors nested inside plain objects/arrays are caught by the same circular
|
|
258
|
-
* check that protects the top-level error tree, rather than only relying on the
|
|
259
|
-
* depth limit.
|
|
260
|
-
*/
|
|
261
|
-
function serializeValue(value, remainingDepth, seen) {
|
|
262
|
-
if (remainingDepth <= 0) return "[Max Depth]";
|
|
263
|
-
if (value === null || value === void 0) return value;
|
|
264
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
265
|
-
if (value instanceof Date) return value.toISOString();
|
|
266
|
-
if (value instanceof Error) {
|
|
267
|
-
if (seen.has(value)) return {
|
|
268
|
-
name: value.name,
|
|
269
|
-
message: value.message,
|
|
270
|
-
_circular: true
|
|
271
|
-
};
|
|
272
|
-
return _serializeError(value, true, remainingDepth, [], 0, seen);
|
|
273
|
-
}
|
|
274
|
-
if (Array.isArray(value)) {
|
|
275
|
-
if (seen.has(value)) return "[Circular]";
|
|
276
|
-
seen.add(value);
|
|
277
|
-
return value.map((item) => serializeValue(item, remainingDepth - 1, seen));
|
|
278
|
-
}
|
|
279
|
-
if (typeof value === "object") {
|
|
280
|
-
if (seen.has(value)) return "[Circular]";
|
|
281
|
-
seen.add(value);
|
|
282
|
-
const out = {};
|
|
283
|
-
for (const [k, v] of Object.entries(value)) try {
|
|
284
|
-
assignOwn(out, k, serializeValue(v, remainingDepth - 1, seen));
|
|
285
|
-
} catch {
|
|
286
|
-
assignOwn(out, k, "[Unserializable]");
|
|
287
|
-
}
|
|
288
|
-
return out;
|
|
289
|
-
}
|
|
290
|
-
return String(value);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Type guard: returns true if the value looks like an Error object.
|
|
294
|
-
*/
|
|
295
|
-
function isError(value) {
|
|
296
|
-
return value instanceof Error || Boolean(value) && typeof value === "object" && "name" in value && "message" in value;
|
|
297
|
-
}
|
|
298
|
-
const MAX_ERROR_SEARCH_DEPTH = 3;
|
|
299
|
-
const MAX_ERROR_SEARCH_NODES = 2e3;
|
|
300
|
-
/**
|
|
301
|
-
* Replaces real Error instances inside a log payload with their serialized form,
|
|
302
|
-
* because JSON output drops an Error's non-enumerable `message` and `stack`. Runs on
|
|
303
|
-
* every log call, so its work is capped and it copies nothing until it finds one.
|
|
304
|
-
* Duck-typed objects are data, and an Error with its own toJSON has already chosen
|
|
305
|
-
* what to show. The caller's objects are never mutated.
|
|
306
|
-
*/
|
|
307
|
-
function serializeNestedErrors(data) {
|
|
308
|
-
const outerBudget = errorSearchBudget;
|
|
309
|
-
errorSearchBudget = MAX_ERROR_SEARCH_NODES;
|
|
310
|
-
try {
|
|
311
|
-
return walkForErrors(data, MAX_ERROR_SEARCH_DEPTH, void 0, void 0);
|
|
312
|
-
} finally {
|
|
313
|
-
errorSearchBudget = outerBudget;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
let errorSearchBudget = 0;
|
|
317
|
-
const hasOwn = Object.prototype.hasOwnProperty;
|
|
318
|
-
function walkForErrors(value, depth, parent, grandparent) {
|
|
319
|
-
if (value instanceof Error) return typeof value.toJSON === "function" ? value : serializeError(value);
|
|
320
|
-
if (depth === 0 || --errorSearchBudget < 0 || value === parent || value === grandparent) return value;
|
|
321
|
-
let copy;
|
|
322
|
-
if (Array.isArray(value)) for (let i = 0; i < value.length; i++) {
|
|
323
|
-
const item = value[i];
|
|
324
|
-
if (item === null || typeof item !== "object") continue;
|
|
325
|
-
const next = walkForErrors(item, depth - 1, value, parent);
|
|
326
|
-
if (next !== item) {
|
|
327
|
-
copy ??= value.slice();
|
|
328
|
-
copy[i] = next;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
const proto = Object.getPrototypeOf(value);
|
|
333
|
-
if (proto !== Object.prototype && proto !== null) return value;
|
|
334
|
-
const record = value;
|
|
335
|
-
for (const key in record) {
|
|
336
|
-
if (!hasOwn.call(record, key)) continue;
|
|
337
|
-
let item;
|
|
338
|
-
try {
|
|
339
|
-
item = record[key];
|
|
340
|
-
} catch {
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
if (item === null || typeof item !== "object") continue;
|
|
344
|
-
const next = walkForErrors(item, depth - 1, record, parent);
|
|
345
|
-
if (next !== item) {
|
|
346
|
-
copy ??= { ...record };
|
|
347
|
-
assignOwn(copy, key, next);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
return copy ?? value;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Coerce any thrown value into a proper Error instance.
|
|
355
|
-
*/
|
|
356
|
-
function normalizeError(error) {
|
|
357
|
-
if (isError(error)) return error;
|
|
358
|
-
if (typeof error === "string") return new Error(error);
|
|
359
|
-
if (typeof error === "object" && error !== null) {
|
|
360
|
-
const e = error;
|
|
361
|
-
const err = new Error(typeof e["message"] === "string" ? e["message"] : "Unknown error");
|
|
362
|
-
Object.assign(err, error);
|
|
363
|
-
return err;
|
|
364
|
-
}
|
|
365
|
-
return new Error(String(error));
|
|
366
|
-
}
|
|
367
184
|
// src/utils/redact.utils.ts
|
|
368
185
|
const DEFAULT_CENSOR = "[REDACTED]";
|
|
369
186
|
/** Maximum nesting depth walked; deeper values are replaced with a marker. */
|
|
@@ -711,12 +528,28 @@ function isCacheableTraceId(id) {
|
|
|
711
528
|
}
|
|
712
529
|
return true;
|
|
713
530
|
}
|
|
531
|
+
/** Maps a trace id to a stable number in [0, 1): FNV-1a followed by a murmur3 finalizer. */
|
|
532
|
+
function traceFraction(id) {
|
|
533
|
+
let h = 2166136261;
|
|
534
|
+
for (let i = 0; i < id.length; i++) {
|
|
535
|
+
h ^= id.charCodeAt(i);
|
|
536
|
+
h = Math.imul(h, 16777619);
|
|
537
|
+
}
|
|
538
|
+
h ^= h >>> 16;
|
|
539
|
+
h = Math.imul(h, 2246822507);
|
|
540
|
+
h ^= h >>> 13;
|
|
541
|
+
h = Math.imul(h, 3266489909);
|
|
542
|
+
h ^= h >>> 16;
|
|
543
|
+
return (h >>> 0) / 4294967296;
|
|
544
|
+
}
|
|
545
|
+
const ADAPTIVE_BUCKETS = 100;
|
|
714
546
|
var Sampler = class {
|
|
715
547
|
config;
|
|
716
548
|
/**
|
|
717
|
-
* Per-trace
|
|
718
|
-
* re-inserts the key).
|
|
719
|
-
*
|
|
549
|
+
* Per-trace sampling fractions in LRU order (Map preserves insertion order; a
|
|
550
|
+
* hit re-inserts the key). A trace is kept at a level when its fraction is below
|
|
551
|
+
* that level's rate, so it is never fixed by the first level seen. Survives
|
|
552
|
+
* resetStats() so a long trace is not re-evaluated mid-flight. Bounded by size, by an idle TTL (refreshed on hit) and by a hard
|
|
720
553
|
* lifetime measured from the first decision.
|
|
721
554
|
*/
|
|
722
555
|
traceDecisions = /* @__PURE__ */ new Map();
|
|
@@ -725,8 +558,11 @@ var Sampler = class {
|
|
|
725
558
|
traceMaxLifetimeMs = 36e5;
|
|
726
559
|
_tokenBucket = 0;
|
|
727
560
|
_lastRefillMs = Date.now();
|
|
728
|
-
|
|
729
|
-
|
|
561
|
+
_adaptiveBucketMs;
|
|
562
|
+
_adaptiveTotals = new Float64Array(ADAPTIVE_BUCKETS);
|
|
563
|
+
_adaptiveErrorCounts = new Float64Array(ADAPTIVE_BUCKETS);
|
|
564
|
+
_adaptiveBucket = 0;
|
|
565
|
+
_adaptiveTotal = 0;
|
|
730
566
|
_adaptiveErrors = 0;
|
|
731
567
|
_stats = {
|
|
732
568
|
evaluated: 0,
|
|
@@ -737,7 +573,9 @@ var Sampler = class {
|
|
|
737
573
|
};
|
|
738
574
|
_statsTimer;
|
|
739
575
|
constructor(config, onStats) {
|
|
576
|
+
var _config$adaptive;
|
|
740
577
|
this.config = config;
|
|
578
|
+
this._adaptiveBucketMs = Math.max(1, Math.ceil((((_config$adaptive = config.adaptive) === null || _config$adaptive === void 0 ? void 0 : _config$adaptive.windowMs) ?? 1e4) / ADAPTIVE_BUCKETS));
|
|
741
579
|
if (config.maxLogsPerSecond && config.maxLogsPerSecond > 0) this._tokenBucket = config.maxLogsPerSecond;
|
|
742
580
|
const interval = config.statsIntervalMs ?? 6e4;
|
|
743
581
|
if (interval > 0 && onStats) {
|
|
@@ -795,34 +633,38 @@ var Sampler = class {
|
|
|
795
633
|
destroy() {
|
|
796
634
|
if (this._statsTimer) clearInterval(this._statsTimer);
|
|
797
635
|
}
|
|
798
|
-
_sampleByRate(level) {
|
|
636
|
+
_sampleByRate(level, fraction) {
|
|
799
637
|
var _this$config$perLevel2, _this$config$perLevel3;
|
|
800
638
|
const baseRate = ((_this$config$perLevel2 = this.config.perLevel) === null || _this$config$perLevel2 === void 0 ? void 0 : _this$config$perLevel2[level]) ?? ((_this$config$perLevel3 = this.config.perLevel) === null || _this$config$perLevel3 === void 0 ? void 0 : _this$config$perLevel3["*"]) ?? this.config.rate ?? 1;
|
|
801
639
|
const rate = Math.max(baseRate, this._adaptiveBoostRate());
|
|
802
640
|
if (rate >= 1) return true;
|
|
803
641
|
if (rate <= 0) return false;
|
|
642
|
+
if (fraction !== void 0) return fraction < rate;
|
|
804
643
|
return Math.random() < rate;
|
|
805
644
|
}
|
|
806
|
-
/**
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const cutoff = now - windowMs;
|
|
818
|
-
const win = this._adaptiveWindow;
|
|
819
|
-
while (this._adaptiveHead < win.length && win[this._adaptiveHead].t < cutoff) {
|
|
820
|
-
if (win[this._adaptiveHead].err) this._adaptiveErrors -= 1;
|
|
821
|
-
this._adaptiveHead += 1;
|
|
645
|
+
/** Moves the ring forward to the bucket holding `now`, dropping buckets that left the window. */
|
|
646
|
+
_advanceAdaptive(now) {
|
|
647
|
+
const target = Math.floor(now / this._adaptiveBucketMs);
|
|
648
|
+
if (target <= this._adaptiveBucket) return this._adaptiveBucket;
|
|
649
|
+
const steps = Math.min(target - this._adaptiveBucket, ADAPTIVE_BUCKETS);
|
|
650
|
+
for (let i = 1; i <= steps; i++) {
|
|
651
|
+
const slot = (this._adaptiveBucket + i) % ADAPTIVE_BUCKETS;
|
|
652
|
+
this._adaptiveTotal -= this._adaptiveTotals[slot];
|
|
653
|
+
this._adaptiveErrors -= this._adaptiveErrorCounts[slot];
|
|
654
|
+
this._adaptiveTotals[slot] = 0;
|
|
655
|
+
this._adaptiveErrorCounts[slot] = 0;
|
|
822
656
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
657
|
+
this._adaptiveBucket = target;
|
|
658
|
+
return target;
|
|
659
|
+
}
|
|
660
|
+
/** Record one evaluated sample in the current bucket. O(1). */
|
|
661
|
+
_recordAdaptiveSample(level) {
|
|
662
|
+
const slot = this._advanceAdaptive(Date.now()) % ADAPTIVE_BUCKETS;
|
|
663
|
+
this._adaptiveTotals[slot] += 1;
|
|
664
|
+
this._adaptiveTotal += 1;
|
|
665
|
+
if (level === "error" || level === "fatal") {
|
|
666
|
+
this._adaptiveErrorCounts[slot] += 1;
|
|
667
|
+
this._adaptiveErrors += 1;
|
|
826
668
|
}
|
|
827
669
|
}
|
|
828
670
|
/**
|
|
@@ -833,8 +675,9 @@ var Sampler = class {
|
|
|
833
675
|
_adaptiveBoostRate() {
|
|
834
676
|
const cfg = this.config.adaptive;
|
|
835
677
|
if (!cfg) return 0;
|
|
678
|
+
this._advanceAdaptive(Date.now());
|
|
836
679
|
const minSamples = cfg.minSamples ?? 20;
|
|
837
|
-
const total = this.
|
|
680
|
+
const total = this._adaptiveTotal;
|
|
838
681
|
if (total < minSamples) return 0;
|
|
839
682
|
return this._adaptiveErrors / total >= (cfg.errorRateThreshold ?? .05) ? cfg.boostRate ?? 1 : 0;
|
|
840
683
|
}
|
|
@@ -843,8 +686,9 @@ var Sampler = class {
|
|
|
843
686
|
return this._adaptiveBoostRate() > 0;
|
|
844
687
|
}
|
|
845
688
|
/**
|
|
846
|
-
*
|
|
847
|
-
* idle past the TTL, or older than the hard lifetime, are
|
|
689
|
+
* Decide a trace by comparing its stable fraction with the level's rate, caching
|
|
690
|
+
* the fraction. Entries idle past the TTL, or older than the hard lifetime, are
|
|
691
|
+
* recomputed; the least
|
|
848
692
|
* recently used entry is evicted once the cap is reached. IDs that are empty,
|
|
849
693
|
* too long or contain control characters are sampled independently and never cached.
|
|
850
694
|
*/
|
|
@@ -856,12 +700,12 @@ var Sampler = class {
|
|
|
856
700
|
this.traceDecisions.delete(traceId);
|
|
857
701
|
known.seenAt = now;
|
|
858
702
|
this.traceDecisions.set(traceId, known);
|
|
859
|
-
return known.
|
|
703
|
+
return this._sampleByRate(level, known.fraction);
|
|
860
704
|
}
|
|
861
|
-
const
|
|
705
|
+
const fraction = traceFraction(traceId);
|
|
862
706
|
this.traceDecisions.delete(traceId);
|
|
863
707
|
this.traceDecisions.set(traceId, {
|
|
864
|
-
|
|
708
|
+
fraction,
|
|
865
709
|
firstAt: now,
|
|
866
710
|
seenAt: now
|
|
867
711
|
});
|
|
@@ -869,7 +713,7 @@ var Sampler = class {
|
|
|
869
713
|
const oldest = this.traceDecisions.keys().next().value;
|
|
870
714
|
if (oldest !== void 0) this.traceDecisions.delete(oldest);
|
|
871
715
|
}
|
|
872
|
-
return
|
|
716
|
+
return this._sampleByRate(level, fraction);
|
|
873
717
|
}
|
|
874
718
|
_consumeToken() {
|
|
875
719
|
const now = Date.now();
|
|
@@ -946,7 +790,8 @@ function deregisterFromShutdown(logger) {
|
|
|
946
790
|
* the process exits. Idempotent — the first call wins and later calls with
|
|
947
791
|
* conflicting options print a warning. The process is ended with 128 + signal
|
|
948
792
|
* number only when logixia's handler is the sole listener for that signal (see
|
|
949
|
-
* `exit`); otherwise it
|
|
793
|
+
* `exit`), closing the loggers first; otherwise it only flushes them and leaves
|
|
794
|
+
* shutdown to the application.
|
|
950
795
|
* Loggers are also flushed (not closed) on `beforeExit`.
|
|
951
796
|
*
|
|
952
797
|
* @example
|
|
@@ -973,7 +818,8 @@ function flushOnExit(options = {}) {
|
|
|
973
818
|
}, timeout).unref() : void 0;
|
|
974
819
|
try {
|
|
975
820
|
if (beforeFlush) await beforeFlush();
|
|
976
|
-
|
|
821
|
+
const ownsExit = shouldExit(signal);
|
|
822
|
+
await Promise.allSettled([...registry].map((logger) => ownsExit || !logger.flush ? logger.close() : logger.flush()));
|
|
977
823
|
if (afterFlush) await afterFlush();
|
|
978
824
|
} catch (err) {
|
|
979
825
|
process.stderr.write(`[logixia] Shutdown hook failed: ${String(err)}\n`);
|
|
@@ -1094,6 +940,27 @@ function nowIso() {
|
|
|
1094
940
|
return _tsCacheStr;
|
|
1095
941
|
}
|
|
1096
942
|
const RESOLVED = Promise.resolve();
|
|
943
|
+
const UNSERIALIZABLE = "[Unserializable]";
|
|
944
|
+
const ANSI_COLORS = /* @__PURE__ */ new Map([
|
|
945
|
+
["black", "\x1B[30m"],
|
|
946
|
+
["red", "\x1B[31m"],
|
|
947
|
+
["green", "\x1B[32m"],
|
|
948
|
+
["yellow", "\x1B[33m"],
|
|
949
|
+
["blue", "\x1B[34m"],
|
|
950
|
+
["magenta", "\x1B[35m"],
|
|
951
|
+
["cyan", "\x1B[36m"],
|
|
952
|
+
["white", "\x1B[37m"],
|
|
953
|
+
["gray", "\x1B[90m"],
|
|
954
|
+
["grey", "\x1B[90m"],
|
|
955
|
+
["brightred", "\x1B[91m"],
|
|
956
|
+
["brightgreen", "\x1B[92m"],
|
|
957
|
+
["brightyellow", "\x1B[93m"],
|
|
958
|
+
["brightblue", "\x1B[94m"],
|
|
959
|
+
["brightmagenta", "\x1B[95m"],
|
|
960
|
+
["brightcyan", "\x1B[96m"],
|
|
961
|
+
["brightwhite", "\x1B[97m"],
|
|
962
|
+
["reset", "\x1B[0m"]
|
|
963
|
+
]);
|
|
1097
964
|
const JSON_STRING_FIELDS = [
|
|
1098
965
|
"timestamp",
|
|
1099
966
|
"level",
|
|
@@ -1130,6 +997,21 @@ function toContextLabel(context) {
|
|
|
1130
997
|
if (context === void 0 || context === null) return "";
|
|
1131
998
|
return typeof context === "string" ? context : safeToString(context);
|
|
1132
999
|
}
|
|
1000
|
+
function serializeErrorSafely(error) {
|
|
1001
|
+
try {
|
|
1002
|
+
return serializeError(error);
|
|
1003
|
+
} catch (cause) {
|
|
1004
|
+
internalError("Error serialization failed", cause);
|
|
1005
|
+
return UNSERIALIZABLE;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
function errorMessageSafely(error) {
|
|
1009
|
+
try {
|
|
1010
|
+
return safeToString(error.message);
|
|
1011
|
+
} catch {
|
|
1012
|
+
return UNSERIALIZABLE;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1133
1015
|
function namespacePatternToRegex(pattern) {
|
|
1134
1016
|
const escaped = pattern.split(".").map((s) => s === "*" ? "[^.]+" : s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("\\.");
|
|
1135
1017
|
return new RegExp(`^${escaped}$`);
|
|
@@ -1215,7 +1097,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1215
1097
|
/** `source=value` pairs already reported as unknown levels — warn once per logger. */
|
|
1216
1098
|
_warnedInvalidLevels = /* @__PURE__ */ new Set();
|
|
1217
1099
|
/** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
|
|
1218
|
-
_colorMap =
|
|
1100
|
+
_colorMap = ANSI_COLORS;
|
|
1219
1101
|
/** Pre-computed field-enabled booleans so isFieldEnabled() isn't called per log. */
|
|
1220
1102
|
_fieldCache = /* @__PURE__ */ new Map();
|
|
1221
1103
|
/** True when contextData is non-empty — avoids Object.keys() check on hot path. */
|
|
@@ -1287,15 +1169,21 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1287
1169
|
}
|
|
1288
1170
|
}
|
|
1289
1171
|
};
|
|
1290
|
-
this.config = {
|
|
1291
|
-
...
|
|
1292
|
-
...config
|
|
1293
|
-
};
|
|
1294
|
-
const resolvedLevel = resolveInitialLevel(this.config);
|
|
1295
|
-
this.config.levelOptions = {
|
|
1296
|
-
...this.config.levelOptions,
|
|
1297
|
-
level: resolvedLevel
|
|
1172
|
+
if (parent) this.config = {
|
|
1173
|
+
...config,
|
|
1174
|
+
levelOptions: { ...config.levelOptions }
|
|
1298
1175
|
};
|
|
1176
|
+
else {
|
|
1177
|
+
this.config = {
|
|
1178
|
+
...defaultConfig,
|
|
1179
|
+
...config
|
|
1180
|
+
};
|
|
1181
|
+
const resolvedLevel = resolveInitialLevel(this.config);
|
|
1182
|
+
this.config.levelOptions = {
|
|
1183
|
+
...this.config.levelOptions,
|
|
1184
|
+
level: resolvedLevel
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1299
1187
|
this.config.fields ??= {
|
|
1300
1188
|
timestamp: "[yyyy-mm-dd HH:MM:ss.MS]",
|
|
1301
1189
|
level: "[log_level]",
|
|
@@ -1330,7 +1218,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1330
1218
|
if (!parent) this.setupGracefulShutdown();
|
|
1331
1219
|
this.createCustomLevelMethods();
|
|
1332
1220
|
if (!parent) for (const p of globalPluginRegistry._plugins) this._pluginRegistry.register(p);
|
|
1333
|
-
this._buildPerfCaches();
|
|
1221
|
+
this._buildPerfCaches(parent);
|
|
1334
1222
|
}
|
|
1335
1223
|
setupGracefulShutdown() {
|
|
1336
1224
|
const shutdownCfg = this.config.gracefulShutdown;
|
|
@@ -1345,19 +1233,34 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1345
1233
|
});
|
|
1346
1234
|
}
|
|
1347
1235
|
createCustomLevelMethods() {
|
|
1348
|
-
var _this$config$levelOpt3
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1236
|
+
var _this$config$levelOpt3;
|
|
1237
|
+
const levels = (_this$config$levelOpt3 = this.config.levelOptions) === null || _this$config$levelOpt3 === void 0 ? void 0 : _this$config$levelOpt3.levels;
|
|
1238
|
+
warnOnReservedLevelNames(levels);
|
|
1239
|
+
if (!levels) return;
|
|
1240
|
+
const self = this;
|
|
1241
|
+
const names = Object.keys(levels);
|
|
1242
|
+
const define = (method, levelName) => {
|
|
1243
|
+
if (!self[method]) self[method] = (message, data) => this.logLevel(levelName, message, data);
|
|
1244
|
+
};
|
|
1245
|
+
for (const levelName of names) define(levelName, levelName);
|
|
1246
|
+
for (const levelName of names) define(levelName.toLowerCase(), levelName);
|
|
1353
1247
|
}
|
|
1354
1248
|
/**
|
|
1355
1249
|
* Rebuild all hot-path caches after any config mutation or level change.
|
|
1356
1250
|
* Keeps the actual log() call free of allocations in the common case.
|
|
1357
1251
|
*/
|
|
1358
|
-
_buildPerfCaches() {
|
|
1359
|
-
var _this$config$
|
|
1360
|
-
|
|
1252
|
+
_buildPerfCaches(inheritFrom) {
|
|
1253
|
+
var _this$config$levelOpt4, _this$config$format, _this$config$redact$p, _this$config$redact$p2;
|
|
1254
|
+
if (inheritFrom && inheritFrom.fieldState.size === 0) {
|
|
1255
|
+
this._levelValues = inheritFrom._levelValues;
|
|
1256
|
+
this._fieldCache = new Map(inheritFrom._fieldCache);
|
|
1257
|
+
this._formattedLevels = inheritFrom._formattedLevels;
|
|
1258
|
+
this._formattedAppName = inheritFrom._formattedAppName;
|
|
1259
|
+
this._hasRedact = inheritFrom._hasRedact;
|
|
1260
|
+
this._minLevelValue = this._levelValues.get(this.resolveEffectiveLevel()) ?? 2;
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
const customLevelEntries = Object.entries(((_this$config$levelOpt4 = this.config.levelOptions) === null || _this$config$levelOpt4 === void 0 ? void 0 : _this$config$levelOpt4.levels) ?? {});
|
|
1361
1264
|
this._levelValues = new Map([
|
|
1362
1265
|
[LogLevel.ERROR, 0],
|
|
1363
1266
|
[LogLevel.WARN, 1],
|
|
@@ -1371,26 +1274,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1371
1274
|
this.config.levelOptions.level = this._validLevel(this.config.levelOptions.level, "levelOptions.level") ?? LogLevel.INFO;
|
|
1372
1275
|
const effectiveLevel = this.resolveEffectiveLevel();
|
|
1373
1276
|
this._minLevelValue = this._levelValues.get(effectiveLevel) ?? 2;
|
|
1374
|
-
this._colorMap =
|
|
1375
|
-
["black", "\x1B[30m"],
|
|
1376
|
-
["red", "\x1B[31m"],
|
|
1377
|
-
["green", "\x1B[32m"],
|
|
1378
|
-
["yellow", "\x1B[33m"],
|
|
1379
|
-
["blue", "\x1B[34m"],
|
|
1380
|
-
["magenta", "\x1B[35m"],
|
|
1381
|
-
["cyan", "\x1B[36m"],
|
|
1382
|
-
["white", "\x1B[37m"],
|
|
1383
|
-
["gray", "\x1B[90m"],
|
|
1384
|
-
["grey", "\x1B[90m"],
|
|
1385
|
-
["brightred", "\x1B[91m"],
|
|
1386
|
-
["brightgreen", "\x1B[92m"],
|
|
1387
|
-
["brightyellow", "\x1B[93m"],
|
|
1388
|
-
["brightblue", "\x1B[94m"],
|
|
1389
|
-
["brightmagenta", "\x1B[95m"],
|
|
1390
|
-
["brightcyan", "\x1B[96m"],
|
|
1391
|
-
["brightwhite", "\x1B[97m"],
|
|
1392
|
-
["reset", "\x1B[0m"]
|
|
1393
|
-
]);
|
|
1277
|
+
this._colorMap = ANSI_COLORS;
|
|
1394
1278
|
for (const f of [
|
|
1395
1279
|
"timestamp",
|
|
1396
1280
|
"level",
|
|
@@ -1426,8 +1310,8 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1426
1310
|
for (const [lvl] of this._levelValues) {
|
|
1427
1311
|
const upper = lvl.toUpperCase();
|
|
1428
1312
|
if (colorize && this._fieldCache.get("level") !== false) {
|
|
1429
|
-
var _this$config$
|
|
1430
|
-
let colorName = (_this$config$
|
|
1313
|
+
var _this$config$levelOpt5;
|
|
1314
|
+
let colorName = (_this$config$levelOpt5 = this.config.levelOptions) === null || _this$config$levelOpt5 === void 0 || (_this$config$levelOpt5 = _this$config$levelOpt5.colors) === null || _this$config$levelOpt5 === void 0 ? void 0 : _this$config$levelOpt5[lvl];
|
|
1431
1315
|
if (!colorName) {
|
|
1432
1316
|
if (_BUILTIN_LEVELS.has(lvl)) colorName = "white";
|
|
1433
1317
|
else {
|
|
@@ -1452,9 +1336,9 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1452
1336
|
*/
|
|
1453
1337
|
error(messageOrError, data) {
|
|
1454
1338
|
try {
|
|
1455
|
-
return isError(messageOrError) ? this._run("error", messageOrError
|
|
1339
|
+
return isError(messageOrError) ? this._run("error", errorMessageSafely(messageOrError), {
|
|
1456
1340
|
...data,
|
|
1457
|
-
error:
|
|
1341
|
+
error: serializeErrorSafely(messageOrError)
|
|
1458
1342
|
}) : this._run("error", messageOrError, data);
|
|
1459
1343
|
} catch (error) {
|
|
1460
1344
|
return Promise.reject(error);
|
|
@@ -1574,8 +1458,8 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1574
1458
|
* else a `NODE_ENV` default (`debug` in development, `warn` in test), else `info`.
|
|
1575
1459
|
*/
|
|
1576
1460
|
getLevel() {
|
|
1577
|
-
var _this$config$
|
|
1578
|
-
return ((_this$config$
|
|
1461
|
+
var _this$config$levelOpt6;
|
|
1462
|
+
return ((_this$config$levelOpt6 = this.config.levelOptions) === null || _this$config$levelOpt6 === void 0 ? void 0 : _this$config$levelOpt6.level) ?? LogLevel.INFO;
|
|
1579
1463
|
}
|
|
1580
1464
|
_validLevelList() {
|
|
1581
1465
|
return [...this._levelValues.keys()].join(", ");
|
|
@@ -1639,6 +1523,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1639
1523
|
/** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
|
|
1640
1524
|
setContext(context) {
|
|
1641
1525
|
this.context = typeof context === "string" ? context : safeToString(context);
|
|
1526
|
+
this._syncNamespaceLevels();
|
|
1642
1527
|
}
|
|
1643
1528
|
/** Return the current context label, or `undefined` if none is set. */
|
|
1644
1529
|
getContext() {
|
|
@@ -1807,7 +1692,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1807
1692
|
const config = this.config;
|
|
1808
1693
|
if (config.silent) return;
|
|
1809
1694
|
if (!this.shouldLog(level)) return;
|
|
1810
|
-
const data = rawData instanceof Error ? { error:
|
|
1695
|
+
const data = rawData instanceof Error ? { error: serializeErrorSafely(rawData) } : rawData;
|
|
1811
1696
|
const alsContext = LogixiaContext.get();
|
|
1812
1697
|
let activeTraceId;
|
|
1813
1698
|
if (config.traceId) {
|
|
@@ -2034,13 +1919,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
2034
1919
|
* ```
|
|
2035
1920
|
*/
|
|
2036
1921
|
function createLogger(config, context) {
|
|
2037
|
-
|
|
2038
|
-
const logger = new LogixiaLogger(config, context);
|
|
2039
|
-
const mutableLogger = logger;
|
|
2040
|
-
if ((_config$levelOptions3 = config.levelOptions) === null || _config$levelOptions3 === void 0 ? void 0 : _config$levelOptions3.levels) {
|
|
2041
|
-
for (const levelName of Object.keys(config.levelOptions.levels)) if (!mutableLogger[levelName]) mutableLogger[levelName] = (message, data) => logger.logLevel(levelName, message, data);
|
|
2042
|
-
}
|
|
2043
|
-
return logger;
|
|
1922
|
+
return new LogixiaLogger(config, context);
|
|
2044
1923
|
}
|
|
2045
1924
|
// src/exceptions/exception.ts
|
|
2046
1925
|
var LogixiaException = class extends Error {
|
|
@@ -2281,6 +2160,6 @@ var ErrorResponseBuilder = class {
|
|
|
2281
2160
|
};
|
|
2282
2161
|
}
|
|
2283
2162
|
};
|
|
2284
|
-
export {
|
|
2163
|
+
export { usePlugin as _, isLogixiaException as a, DEFAULT_LOG_LEVELS as b, _shutdownRegistrySize as c, registerForShutdown as d, resetShutdownHandlers as f, globalPluginRegistry as g, PluginRegistry as h, LogixiaException as i, deregisterFromShutdown as l, redactObject as m, generateRequestId as n, LogixiaLogger as o, applyRedaction as p, generateTraceId as r, createLogger as s, ErrorResponseBuilder as t, flushOnExit as u, DEFAULT_CONFIG as v, LogLevel as x, DEFAULT_LOG_COLORS as y };
|
|
2285
2164
|
|
|
2286
|
-
//# sourceMappingURL=builder-
|
|
2165
|
+
//# sourceMappingURL=builder-CbttbixM.mjs.map
|