logixia 1.3.0 → 1.4.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 +848 -7
- package/dist/.tsbuildinfo +1 -0
- package/dist/{index-iDTW2-eY.d.mts → index-Ium497V3.d.mts} +180 -2
- package/dist/index-Ium497V3.d.mts.map +1 -0
- package/dist/{index-CHIsdA9n.d.ts → index-t-ActikQ.d.ts} +180 -2
- package/dist/index-t-ActikQ.d.ts.map +1 -0
- package/dist/index.d.mts +458 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +458 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +436 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +416 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{logitron-logger.module-C0G8JGVf.d.ts → logitron-logger.module-9vOhKWDG.d.ts} +120 -6
- package/dist/logitron-logger.module-9vOhKWDG.d.ts.map +1 -0
- package/dist/{logitron-logger.module-2AzkadqZ.mjs → logitron-logger.module-C939PIEV.mjs} +331 -10
- package/dist/logitron-logger.module-C939PIEV.mjs.map +1 -0
- package/dist/{logitron-logger.module-BqNKp0Fs.js → logitron-logger.module-CCnX7GwK.js} +383 -8
- package/dist/logitron-logger.module-CCnX7GwK.js.map +1 -0
- package/dist/{logitron-logger.module-DQKaZTJL.d.mts → logitron-logger.module-SArymP6b.d.mts} +120 -6
- package/dist/logitron-logger.module-SArymP6b.d.mts.map +1 -0
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/nest.d.mts +2 -2
- package/dist/nest.d.ts +2 -2
- package/dist/nest.js +2 -2
- package/dist/nest.mjs +2 -2
- package/dist/{promise-DaiZ2BaH.js → promise-BI-3eI4n.js} +285 -128
- package/dist/promise-BI-3eI4n.js.map +1 -0
- package/dist/{promise-C4pQPcK4.mjs → promise-BrZcjavs.mjs} +285 -128
- package/dist/promise-BrZcjavs.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +7 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +7 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.manager-5VVdqS3o.mjs → transport.manager-DR7TLXQT.mjs} +82 -4
- package/dist/transport.manager-DR7TLXQT.mjs.map +1 -0
- package/dist/{transport.manager-DCOm4uIQ.js → transport.manager-DVTM978M.js} +82 -4
- package/dist/transport.manager-DVTM978M.js.map +1 -0
- package/dist/transports.d.mts +61 -168
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +61 -168
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +1 -1
- package/dist/transports.mjs +1 -1
- package/package.json +72 -9
- package/dist/index-CHIsdA9n.d.ts.map +0 -1
- package/dist/index-iDTW2-eY.d.mts.map +0 -1
- package/dist/logitron-logger.module-2AzkadqZ.mjs.map +0 -1
- package/dist/logitron-logger.module-BqNKp0Fs.js.map +0 -1
- package/dist/logitron-logger.module-C0G8JGVf.d.ts.map +0 -1
- package/dist/logitron-logger.module-DQKaZTJL.d.mts.map +0 -1
- package/dist/promise-C4pQPcK4.mjs.map +0 -1
- package/dist/promise-DaiZ2BaH.js.map +0 -1
- package/dist/transport.manager-5VVdqS3o.mjs.map +0 -1
- package/dist/transport.manager-DCOm4uIQ.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as __toESM, t as __commonJS } from "./chunk-uEZWKkIX.mjs";
|
|
2
|
-
import { d as internalLog, f as internalWarn, t as TransportManager, u as internalError } from "./transport.manager-
|
|
1
|
+
import { a as __toESM, r as __require, t as __commonJS } from "./chunk-uEZWKkIX.mjs";
|
|
2
|
+
import { d as internalLog, f as internalWarn, t as TransportManager, u as internalError } from "./transport.manager-DR7TLXQT.mjs";
|
|
3
3
|
import buildFastStringify from "fast-json-stringify";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
import crypto$1 from "crypto";
|
|
@@ -73,6 +73,103 @@ function createFastifyContextHook(options = {}) {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/plugin.ts
|
|
78
|
+
/**
|
|
79
|
+
* Holds an ordered list of `LogixiaPlugin` instances and dispatches lifecycle
|
|
80
|
+
* events to them. One registry is created per logger instance; a global
|
|
81
|
+
* singleton is also exported for process-wide registration.
|
|
82
|
+
*/
|
|
83
|
+
var PluginRegistry = class {
|
|
84
|
+
constructor() {
|
|
85
|
+
this._plugins = [];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Register a plugin. Silently skips if a plugin with the same `name` is
|
|
89
|
+
* already registered on this registry.
|
|
90
|
+
*/
|
|
91
|
+
register(plugin) {
|
|
92
|
+
if (this._plugins.some((p) => p.name === plugin.name)) return;
|
|
93
|
+
this._plugins.push(plugin);
|
|
94
|
+
if (plugin.onInit) {
|
|
95
|
+
const result = plugin.onInit();
|
|
96
|
+
if (result instanceof Promise) result.catch(() => {});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Remove a previously registered plugin by name. No-op if not found. */
|
|
100
|
+
unregister(name) {
|
|
101
|
+
const idx = this._plugins.findIndex((p) => p.name === name);
|
|
102
|
+
if (idx !== -1) this._plugins.splice(idx, 1);
|
|
103
|
+
}
|
|
104
|
+
/** Returns `true` if a plugin with the given name is registered. */
|
|
105
|
+
has(name) {
|
|
106
|
+
return this._plugins.some((p) => p.name === name);
|
|
107
|
+
}
|
|
108
|
+
/** Number of currently registered plugins. */
|
|
109
|
+
get size() {
|
|
110
|
+
return this._plugins.length;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Run all `onLog` hooks in order.
|
|
114
|
+
* Returns `null` if any plugin cancels the entry; otherwise returns the
|
|
115
|
+
* (possibly transformed) entry.
|
|
116
|
+
*/
|
|
117
|
+
async runOnLog(entry) {
|
|
118
|
+
let current = entry;
|
|
119
|
+
for (const plugin of this._plugins) {
|
|
120
|
+
if (!plugin.onLog) continue;
|
|
121
|
+
current = await plugin.onLog(current);
|
|
122
|
+
if (current === null) return null;
|
|
123
|
+
}
|
|
124
|
+
return current;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Notify all `onError` hooks.
|
|
128
|
+
* Errors thrown inside hooks are swallowed to prevent error cascades.
|
|
129
|
+
*/
|
|
130
|
+
async runOnError(error, entry) {
|
|
131
|
+
for (const plugin of this._plugins) if (plugin.onError) {
|
|
132
|
+
const r = plugin.onError(error, entry);
|
|
133
|
+
if (r instanceof Promise) await r.catch(() => {});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** Run all `onShutdown` hooks concurrently. Hook errors are swallowed. */
|
|
137
|
+
async runOnShutdown() {
|
|
138
|
+
await Promise.all(this._plugins.filter((p) => Boolean(p.onShutdown)).map((p) => {
|
|
139
|
+
const r = p.onShutdown();
|
|
140
|
+
return r instanceof Promise ? r.catch(() => {}) : Promise.resolve();
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Module-level singleton registry.
|
|
146
|
+
*
|
|
147
|
+
* Plugins registered here are automatically copied into every **new** logger
|
|
148
|
+
* instance created after the registration. Already-created loggers are not
|
|
149
|
+
* retroactively affected — use `logger.use(plugin)` for per-instance control.
|
|
150
|
+
*/
|
|
151
|
+
const globalPluginRegistry = new PluginRegistry();
|
|
152
|
+
/**
|
|
153
|
+
* Register a plugin in the global registry so it applies to every future
|
|
154
|
+
* logger instance.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { usePlugin } from 'logixia';
|
|
159
|
+
*
|
|
160
|
+
* usePlugin({
|
|
161
|
+
* name: 'audit-sink',
|
|
162
|
+
* onLog(entry) {
|
|
163
|
+
* if (entry.level === 'error') auditQueue.push(entry);
|
|
164
|
+
* return entry;
|
|
165
|
+
* },
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
function usePlugin(plugin) {
|
|
170
|
+
globalPluginRegistry.register(plugin);
|
|
171
|
+
}
|
|
172
|
+
|
|
76
173
|
//#endregion
|
|
77
174
|
//#region src/types/index.ts
|
|
78
175
|
const LogLevel = {
|
|
@@ -210,10 +307,187 @@ function normalizeError(error) {
|
|
|
210
307
|
return new Error(String(error));
|
|
211
308
|
}
|
|
212
309
|
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/utils/otel.ts
|
|
312
|
+
let _otelApi;
|
|
313
|
+
function tryLoadOtelApi() {
|
|
314
|
+
if (_otelApi !== void 0) return _otelApi;
|
|
315
|
+
try {
|
|
316
|
+
_otelApi = __require("@opentelemetry/api");
|
|
317
|
+
return _otelApi;
|
|
318
|
+
} catch {
|
|
319
|
+
_otelApi = null;
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Read the currently active OTel span context (if any) and return its fields
|
|
325
|
+
* in a plain object suitable for spreading into a log entry.
|
|
326
|
+
*
|
|
327
|
+
* Returns `undefined` when:
|
|
328
|
+
* - `@opentelemetry/api` is not installed
|
|
329
|
+
* - No active span exists (root context)
|
|
330
|
+
* - The span context is invalid (all-zeros)
|
|
331
|
+
*/
|
|
332
|
+
function getActiveOtelContext(opts = {}) {
|
|
333
|
+
const api = tryLoadOtelApi();
|
|
334
|
+
if (!api) return void 0;
|
|
335
|
+
const ctx = api.context.active();
|
|
336
|
+
const sc = api.trace.getSpanContext(ctx);
|
|
337
|
+
if (!sc || !api.trace.isSpanContextValid(sc)) return void 0;
|
|
338
|
+
const isSampled = (sc.traceFlags & api.trace.TraceFlags.SAMPLED) === api.trace.TraceFlags.SAMPLED;
|
|
339
|
+
if (opts.sampledOnly && !isSampled) return void 0;
|
|
340
|
+
return {
|
|
341
|
+
traceId: sc.traceId,
|
|
342
|
+
spanId: sc.spanId,
|
|
343
|
+
traceFlags: sc.traceFlags,
|
|
344
|
+
isSampled
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Returns a metadata object with OTel context fields ready to merge into a log call,
|
|
349
|
+
* using the configured field names.
|
|
350
|
+
*
|
|
351
|
+
* Returns `{}` when no active span exists (safe to spread unconditionally).
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* await logger.info('Payment processed', {
|
|
356
|
+
* ...getOtelMetaFields(),
|
|
357
|
+
* orderId: 'ord_123',
|
|
358
|
+
* });
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
function getOtelMetaFields(opts = {}) {
|
|
362
|
+
const { traceIdField = "traceId", spanIdField = "spanId", traceFlagsField = "traceFlags" } = opts;
|
|
363
|
+
const ctx = getActiveOtelContext(opts);
|
|
364
|
+
if (!ctx) return {};
|
|
365
|
+
return {
|
|
366
|
+
[traceIdField]: ctx.traceId,
|
|
367
|
+
[spanIdField]: ctx.spanId,
|
|
368
|
+
[traceFlagsField]: ctx.traceFlags
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
let _bridgeOptions = null;
|
|
372
|
+
/**
|
|
373
|
+
* Initialise the global OTel bridge.
|
|
374
|
+
*
|
|
375
|
+
* Once called, logixia's internal log pipeline checks for an active OTel span
|
|
376
|
+
* on **every** log call and automatically merges the span context into the
|
|
377
|
+
* entry's metadata — no per-call wiring needed.
|
|
378
|
+
*
|
|
379
|
+
* Call once at app startup, **after** the OTel SDK has been initialised:
|
|
380
|
+
* ```ts
|
|
381
|
+
* import { initOtelBridge } from 'logixia';
|
|
382
|
+
* initOtelBridge();
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
function initOtelBridge(opts = {}) {
|
|
386
|
+
_bridgeOptions = opts;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @internal
|
|
390
|
+
* Used by the core logger to inject OTel context when the bridge is active.
|
|
391
|
+
* Returns `{}` when the bridge is not initialised or no active span exists.
|
|
392
|
+
*/
|
|
393
|
+
function _getOtelPayloadIfEnabled() {
|
|
394
|
+
if (!_bridgeOptions) return {};
|
|
395
|
+
return getOtelMetaFields(_bridgeOptions);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Disable the OTel bridge (useful for tests).
|
|
399
|
+
*/
|
|
400
|
+
function disableOtelBridge() {
|
|
401
|
+
_bridgeOptions = null;
|
|
402
|
+
}
|
|
403
|
+
|
|
213
404
|
//#endregion
|
|
214
405
|
//#region src/utils/redact.utils.ts
|
|
215
406
|
const DEFAULT_CENSOR = "[REDACTED]";
|
|
216
407
|
/**
|
|
408
|
+
* Conservative patterns: tokens and secrets that should NEVER appear in logs.
|
|
409
|
+
* Applied when `autoDetect: true` or `autoDetect: 'conservative'`.
|
|
410
|
+
*/
|
|
411
|
+
const PII_CONSERVATIVE_PATTERNS = [
|
|
412
|
+
/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g,
|
|
413
|
+
/Bearer\s+[A-Za-z0-9._~+/-]+=*/gi,
|
|
414
|
+
/\b(?:sk|pk|api|key|secret|token)-[A-Za-z0-9_-]{16,}/gi,
|
|
415
|
+
/\bAKIA[0-9A-Z]{16}\b/g,
|
|
416
|
+
/\b[A-Za-z0-9/+]{40}\b(?=.*aws)/gi
|
|
417
|
+
];
|
|
418
|
+
/**
|
|
419
|
+
* Conservative field-name paths auto-redacted by name regardless of value.
|
|
420
|
+
*/
|
|
421
|
+
const PII_CONSERVATIVE_PATHS = [
|
|
422
|
+
"**.password",
|
|
423
|
+
"**.passwd",
|
|
424
|
+
"**.secret",
|
|
425
|
+
"**.token",
|
|
426
|
+
"**.apiKey",
|
|
427
|
+
"**.api_key",
|
|
428
|
+
"**.accessToken",
|
|
429
|
+
"**.access_token",
|
|
430
|
+
"**.refreshToken",
|
|
431
|
+
"**.refresh_token",
|
|
432
|
+
"**.authorization",
|
|
433
|
+
"**.credentials",
|
|
434
|
+
"**.privateKey",
|
|
435
|
+
"**.private_key",
|
|
436
|
+
"**.clientSecret",
|
|
437
|
+
"**.client_secret"
|
|
438
|
+
];
|
|
439
|
+
/**
|
|
440
|
+
* Aggressive patterns: also catch personal data that could identify a person.
|
|
441
|
+
* Applied when `autoDetect: 'aggressive'`.
|
|
442
|
+
*/
|
|
443
|
+
const PII_AGGRESSIVE_PATTERNS = [
|
|
444
|
+
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
445
|
+
/\b\d{3}-?\d{2}-?\d{4}\b/g,
|
|
446
|
+
/\b(?:\d[ -]?){13,19}\b/g,
|
|
447
|
+
/\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g,
|
|
448
|
+
/\b(?:\d{1,3}\.){3}\d{1,3}\b/g
|
|
449
|
+
];
|
|
450
|
+
const PII_AGGRESSIVE_PATHS = [
|
|
451
|
+
...PII_CONSERVATIVE_PATHS,
|
|
452
|
+
"**.email",
|
|
453
|
+
"**.emailAddress",
|
|
454
|
+
"**.email_address",
|
|
455
|
+
"**.phone",
|
|
456
|
+
"**.phoneNumber",
|
|
457
|
+
"**.phone_number",
|
|
458
|
+
"**.mobile",
|
|
459
|
+
"**.ssn",
|
|
460
|
+
"**.sin",
|
|
461
|
+
"**.dob",
|
|
462
|
+
"**.dateOfBirth",
|
|
463
|
+
"**.date_of_birth",
|
|
464
|
+
"**.creditCard",
|
|
465
|
+
"**.credit_card",
|
|
466
|
+
"**.cardNumber",
|
|
467
|
+
"**.card_number",
|
|
468
|
+
"**.cvv",
|
|
469
|
+
"**.cvc",
|
|
470
|
+
"**.ipAddress",
|
|
471
|
+
"**.ip_address"
|
|
472
|
+
];
|
|
473
|
+
/**
|
|
474
|
+
* Build an effective config that merges `autoDetect` PII rules into the
|
|
475
|
+
* explicit `paths` and `patterns` the caller provided.
|
|
476
|
+
*/
|
|
477
|
+
function resolveConfig(config) {
|
|
478
|
+
const { autoDetect } = config;
|
|
479
|
+
if (!autoDetect) return config;
|
|
480
|
+
const aggressive = autoDetect === "aggressive";
|
|
481
|
+
const extraPaths = aggressive ? PII_AGGRESSIVE_PATHS : PII_CONSERVATIVE_PATHS;
|
|
482
|
+
const extraPatterns = aggressive ? [...PII_CONSERVATIVE_PATTERNS, ...PII_AGGRESSIVE_PATTERNS] : PII_CONSERVATIVE_PATTERNS;
|
|
483
|
+
const { paths = [], patterns = [] } = config;
|
|
484
|
+
return {
|
|
485
|
+
...config,
|
|
486
|
+
paths: [...paths, ...extraPaths],
|
|
487
|
+
patterns: [...patterns, ...extraPatterns]
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
217
491
|
* Convert a dot-notation path pattern to a RegExp.
|
|
218
492
|
* Supports `*` (one segment) and `**` (zero or more segments).
|
|
219
493
|
*
|
|
@@ -285,8 +559,9 @@ function redactObject(obj, config, _currentPath = "") {
|
|
|
285
559
|
*/
|
|
286
560
|
function applyRedaction(payload, config) {
|
|
287
561
|
if (!payload || !config) return payload;
|
|
288
|
-
|
|
289
|
-
|
|
562
|
+
const resolved$1 = resolveConfig(config);
|
|
563
|
+
if ((!resolved$1.paths || resolved$1.paths.length === 0) && (!resolved$1.patterns || resolved$1.patterns.length === 0)) return payload;
|
|
564
|
+
return redactObject(payload, resolved$1);
|
|
290
565
|
}
|
|
291
566
|
function isPlainObject(value) {
|
|
292
567
|
return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Error) && !(value instanceof RegExp);
|
|
@@ -662,11 +937,17 @@ function namespacePatternToRegex(pattern) {
|
|
|
662
937
|
const escaped = pattern.split(".").map((s) => s === "*" ? "[^.]+" : s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("\\.");
|
|
663
938
|
return /* @__PURE__ */ new RegExp(`^${escaped}$`);
|
|
664
939
|
}
|
|
940
|
+
/** Max compiled patterns to keep in memory. Oldest entry is evicted when full. */
|
|
941
|
+
const _NS_CACHE_MAX = 1e3;
|
|
665
942
|
const _nsPatternCache = /* @__PURE__ */ new Map();
|
|
666
943
|
function matchesNamespacePattern(ns, pattern) {
|
|
667
944
|
let re = _nsPatternCache.get(pattern);
|
|
668
945
|
if (!re) {
|
|
669
946
|
re = namespacePatternToRegex(pattern);
|
|
947
|
+
if (_nsPatternCache.size >= _NS_CACHE_MAX) {
|
|
948
|
+
const firstKey = _nsPatternCache.keys().next().value;
|
|
949
|
+
if (firstKey !== void 0) _nsPatternCache.delete(firstKey);
|
|
950
|
+
}
|
|
670
951
|
_nsPatternCache.set(pattern, re);
|
|
671
952
|
}
|
|
672
953
|
return re.test(ns);
|
|
@@ -697,6 +978,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
697
978
|
this._formattedLevels = /* @__PURE__ */ new Map();
|
|
698
979
|
this._formattedAppName = "";
|
|
699
980
|
this._hasRedact = false;
|
|
981
|
+
this._pluginRegistry = new PluginRegistry();
|
|
700
982
|
this.config = {
|
|
701
983
|
appName: "App",
|
|
702
984
|
environment: "development",
|
|
@@ -753,6 +1035,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
753
1035
|
});
|
|
754
1036
|
this.setupGracefulShutdown();
|
|
755
1037
|
this.createCustomLevelMethods();
|
|
1038
|
+
for (const p of globalPluginRegistry._plugins) this._pluginRegistry.register(p);
|
|
756
1039
|
this._buildPerfCaches();
|
|
757
1040
|
}
|
|
758
1041
|
setupGracefulShutdown() {
|
|
@@ -979,6 +1262,29 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
979
1262
|
};
|
|
980
1263
|
return childLogger;
|
|
981
1264
|
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Register a plugin on this logger instance.
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* ```ts
|
|
1270
|
+
* logger.use({
|
|
1271
|
+
* name: 'audit',
|
|
1272
|
+
* onLog(entry) { auditQueue.push(entry); return entry; },
|
|
1273
|
+
* });
|
|
1274
|
+
* ```
|
|
1275
|
+
*/
|
|
1276
|
+
use(plugin) {
|
|
1277
|
+
this._pluginRegistry.register(plugin);
|
|
1278
|
+
return this;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Remove a previously registered plugin by name.
|
|
1282
|
+
* No-op if the plugin is not registered on this instance.
|
|
1283
|
+
*/
|
|
1284
|
+
unuse(pluginName) {
|
|
1285
|
+
this._pluginRegistry.unregister(pluginName);
|
|
1286
|
+
return this;
|
|
1287
|
+
}
|
|
982
1288
|
async flush() {
|
|
983
1289
|
if (this.transportManager) await this.transportManager.flush();
|
|
984
1290
|
}
|
|
@@ -1001,6 +1307,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1001
1307
|
await this.transportManager.close();
|
|
1002
1308
|
}
|
|
1003
1309
|
(_this$_sampler = this._sampler) === null || _this$_sampler === void 0 || _this$_sampler.destroy();
|
|
1310
|
+
await this._pluginRegistry.runOnShutdown();
|
|
1004
1311
|
deregisterFromShutdown(this);
|
|
1005
1312
|
}
|
|
1006
1313
|
async log(level, message, data) {
|
|
@@ -1011,10 +1318,19 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1011
1318
|
if (!this._sampler.shouldEmit(level, traceId$1)) return;
|
|
1012
1319
|
}
|
|
1013
1320
|
const alsContext = LogixiaContext.get();
|
|
1014
|
-
const
|
|
1321
|
+
const otelFields = _getOtelPayloadIfEnabled();
|
|
1322
|
+
const hasOtel = Object.keys(otelFields).length > 0;
|
|
1323
|
+
let mergedData;
|
|
1324
|
+
if (alsContext && Object.keys(alsContext).length > 0) mergedData = {
|
|
1015
1325
|
...alsContext,
|
|
1326
|
+
...hasOtel ? otelFields : {},
|
|
1327
|
+
...data
|
|
1328
|
+
};
|
|
1329
|
+
else if (hasOtel) mergedData = {
|
|
1330
|
+
...otelFields,
|
|
1016
1331
|
...data
|
|
1017
|
-
}
|
|
1332
|
+
};
|
|
1333
|
+
else mergedData = data;
|
|
1018
1334
|
const rawPayload = this._hasContextData ? {
|
|
1019
1335
|
...this.contextData,
|
|
1020
1336
|
...mergedData
|
|
@@ -1032,8 +1348,13 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1032
1348
|
if (this.context) entry.context = this.context;
|
|
1033
1349
|
if (payload !== void 0) entry.payload = payload;
|
|
1034
1350
|
if (traceId !== void 0) entry.traceId = traceId;
|
|
1035
|
-
|
|
1036
|
-
|
|
1351
|
+
let finalEntry = entry;
|
|
1352
|
+
if (this._pluginRegistry.size > 0) {
|
|
1353
|
+
finalEntry = await this._pluginRegistry.runOnLog(entry);
|
|
1354
|
+
if (finalEntry === null) return;
|
|
1355
|
+
}
|
|
1356
|
+
const formattedLog = this.formatLog(finalEntry);
|
|
1357
|
+
await this.output(formattedLog, level, finalEntry);
|
|
1037
1358
|
}
|
|
1038
1359
|
/**
|
|
1039
1360
|
* Hot-path level check: a single Map lookup + integer compare.
|
|
@@ -10521,5 +10842,5 @@ let LogixiaLoggerModule = class LogixiaLoggerModule$1 {
|
|
|
10521
10842
|
LogixiaLoggerModule = _LogixiaLoggerModule = __decorate([Module({})], LogixiaLoggerModule);
|
|
10522
10843
|
|
|
10523
10844
|
//#endregion
|
|
10524
|
-
export {
|
|
10525
|
-
//# sourceMappingURL=logitron-logger.module-
|
|
10845
|
+
export { isError as A, createExpressContextMiddleware as B, resetShutdownHandlers as C, getActiveOtelContext as D, disableOtelBridge as E, LogLevel as F, PluginRegistry as I, globalPluginRegistry as L, serializeError as M, DEFAULT_LOG_COLORS as N, getOtelMetaFields as O, DEFAULT_LOG_LEVELS as P, usePlugin as R, registerForShutdown as S, redactObject as T, createFastifyContextHook as V, runWithTraceId as _, TraceMiddleware as a, deregisterFromShutdown as b, __decorate as c, createLogger as d, DEFAULT_TRACE_HEADERS$1 as f, getCurrentTraceId as g, generateTraceId as h, WebSocketTraceInterceptor as i, normalizeError as j, initOtelBridge as k, __decorateMetadata as l, extractTraceId as m, LOGIXIA_LOGGER_PREFIX as n, KafkaTraceInterceptor as o, createTraceMiddleware as p, LogixiaLoggerModule as r, LogixiaLoggerService as s, LOGIXIA_LOGGER_CONFIG as t, LogixiaLogger as u, setTraceId as v, applyRedaction as w, flushOnExit as x, traceStorage as y, LogixiaContext as z };
|
|
10846
|
+
//# sourceMappingURL=logitron-logger.module-C939PIEV.mjs.map
|