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
1
|
const require_chunk = require('./chunk-BTgCAUrQ.js');
|
|
2
|
-
const require_transport_manager = require('./transport.manager-
|
|
2
|
+
const require_transport_manager = require('./transport.manager-DVTM978M.js');
|
|
3
3
|
let fast_json_stringify = require("fast-json-stringify");
|
|
4
4
|
fast_json_stringify = require_chunk.__toESM(fast_json_stringify);
|
|
5
5
|
let node_async_hooks = require("node:async_hooks");
|
|
@@ -77,6 +77,103 @@ function createFastifyContextHook(options = {}) {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/plugin.ts
|
|
82
|
+
/**
|
|
83
|
+
* Holds an ordered list of `LogixiaPlugin` instances and dispatches lifecycle
|
|
84
|
+
* events to them. One registry is created per logger instance; a global
|
|
85
|
+
* singleton is also exported for process-wide registration.
|
|
86
|
+
*/
|
|
87
|
+
var PluginRegistry = class {
|
|
88
|
+
constructor() {
|
|
89
|
+
this._plugins = [];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Register a plugin. Silently skips if a plugin with the same `name` is
|
|
93
|
+
* already registered on this registry.
|
|
94
|
+
*/
|
|
95
|
+
register(plugin) {
|
|
96
|
+
if (this._plugins.some((p) => p.name === plugin.name)) return;
|
|
97
|
+
this._plugins.push(plugin);
|
|
98
|
+
if (plugin.onInit) {
|
|
99
|
+
const result = plugin.onInit();
|
|
100
|
+
if (result instanceof Promise) result.catch(() => {});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Remove a previously registered plugin by name. No-op if not found. */
|
|
104
|
+
unregister(name) {
|
|
105
|
+
const idx = this._plugins.findIndex((p) => p.name === name);
|
|
106
|
+
if (idx !== -1) this._plugins.splice(idx, 1);
|
|
107
|
+
}
|
|
108
|
+
/** Returns `true` if a plugin with the given name is registered. */
|
|
109
|
+
has(name) {
|
|
110
|
+
return this._plugins.some((p) => p.name === name);
|
|
111
|
+
}
|
|
112
|
+
/** Number of currently registered plugins. */
|
|
113
|
+
get size() {
|
|
114
|
+
return this._plugins.length;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Run all `onLog` hooks in order.
|
|
118
|
+
* Returns `null` if any plugin cancels the entry; otherwise returns the
|
|
119
|
+
* (possibly transformed) entry.
|
|
120
|
+
*/
|
|
121
|
+
async runOnLog(entry) {
|
|
122
|
+
let current = entry;
|
|
123
|
+
for (const plugin of this._plugins) {
|
|
124
|
+
if (!plugin.onLog) continue;
|
|
125
|
+
current = await plugin.onLog(current);
|
|
126
|
+
if (current === null) return null;
|
|
127
|
+
}
|
|
128
|
+
return current;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Notify all `onError` hooks.
|
|
132
|
+
* Errors thrown inside hooks are swallowed to prevent error cascades.
|
|
133
|
+
*/
|
|
134
|
+
async runOnError(error, entry) {
|
|
135
|
+
for (const plugin of this._plugins) if (plugin.onError) {
|
|
136
|
+
const r = plugin.onError(error, entry);
|
|
137
|
+
if (r instanceof Promise) await r.catch(() => {});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/** Run all `onShutdown` hooks concurrently. Hook errors are swallowed. */
|
|
141
|
+
async runOnShutdown() {
|
|
142
|
+
await Promise.all(this._plugins.filter((p) => Boolean(p.onShutdown)).map((p) => {
|
|
143
|
+
const r = p.onShutdown();
|
|
144
|
+
return r instanceof Promise ? r.catch(() => {}) : Promise.resolve();
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Module-level singleton registry.
|
|
150
|
+
*
|
|
151
|
+
* Plugins registered here are automatically copied into every **new** logger
|
|
152
|
+
* instance created after the registration. Already-created loggers are not
|
|
153
|
+
* retroactively affected — use `logger.use(plugin)` for per-instance control.
|
|
154
|
+
*/
|
|
155
|
+
const globalPluginRegistry = new PluginRegistry();
|
|
156
|
+
/**
|
|
157
|
+
* Register a plugin in the global registry so it applies to every future
|
|
158
|
+
* logger instance.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* import { usePlugin } from 'logixia';
|
|
163
|
+
*
|
|
164
|
+
* usePlugin({
|
|
165
|
+
* name: 'audit-sink',
|
|
166
|
+
* onLog(entry) {
|
|
167
|
+
* if (entry.level === 'error') auditQueue.push(entry);
|
|
168
|
+
* return entry;
|
|
169
|
+
* },
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
function usePlugin(plugin) {
|
|
174
|
+
globalPluginRegistry.register(plugin);
|
|
175
|
+
}
|
|
176
|
+
|
|
80
177
|
//#endregion
|
|
81
178
|
//#region src/types/index.ts
|
|
82
179
|
const LogLevel = {
|
|
@@ -214,10 +311,187 @@ function normalizeError(error) {
|
|
|
214
311
|
return new Error(String(error));
|
|
215
312
|
}
|
|
216
313
|
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/utils/otel.ts
|
|
316
|
+
let _otelApi;
|
|
317
|
+
function tryLoadOtelApi() {
|
|
318
|
+
if (_otelApi !== void 0) return _otelApi;
|
|
319
|
+
try {
|
|
320
|
+
_otelApi = require("@opentelemetry/api");
|
|
321
|
+
return _otelApi;
|
|
322
|
+
} catch {
|
|
323
|
+
_otelApi = null;
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Read the currently active OTel span context (if any) and return its fields
|
|
329
|
+
* in a plain object suitable for spreading into a log entry.
|
|
330
|
+
*
|
|
331
|
+
* Returns `undefined` when:
|
|
332
|
+
* - `@opentelemetry/api` is not installed
|
|
333
|
+
* - No active span exists (root context)
|
|
334
|
+
* - The span context is invalid (all-zeros)
|
|
335
|
+
*/
|
|
336
|
+
function getActiveOtelContext(opts = {}) {
|
|
337
|
+
const api = tryLoadOtelApi();
|
|
338
|
+
if (!api) return void 0;
|
|
339
|
+
const ctx = api.context.active();
|
|
340
|
+
const sc = api.trace.getSpanContext(ctx);
|
|
341
|
+
if (!sc || !api.trace.isSpanContextValid(sc)) return void 0;
|
|
342
|
+
const isSampled = (sc.traceFlags & api.trace.TraceFlags.SAMPLED) === api.trace.TraceFlags.SAMPLED;
|
|
343
|
+
if (opts.sampledOnly && !isSampled) return void 0;
|
|
344
|
+
return {
|
|
345
|
+
traceId: sc.traceId,
|
|
346
|
+
spanId: sc.spanId,
|
|
347
|
+
traceFlags: sc.traceFlags,
|
|
348
|
+
isSampled
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Returns a metadata object with OTel context fields ready to merge into a log call,
|
|
353
|
+
* using the configured field names.
|
|
354
|
+
*
|
|
355
|
+
* Returns `{}` when no active span exists (safe to spread unconditionally).
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* await logger.info('Payment processed', {
|
|
360
|
+
* ...getOtelMetaFields(),
|
|
361
|
+
* orderId: 'ord_123',
|
|
362
|
+
* });
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
function getOtelMetaFields(opts = {}) {
|
|
366
|
+
const { traceIdField = "traceId", spanIdField = "spanId", traceFlagsField = "traceFlags" } = opts;
|
|
367
|
+
const ctx = getActiveOtelContext(opts);
|
|
368
|
+
if (!ctx) return {};
|
|
369
|
+
return {
|
|
370
|
+
[traceIdField]: ctx.traceId,
|
|
371
|
+
[spanIdField]: ctx.spanId,
|
|
372
|
+
[traceFlagsField]: ctx.traceFlags
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
let _bridgeOptions = null;
|
|
376
|
+
/**
|
|
377
|
+
* Initialise the global OTel bridge.
|
|
378
|
+
*
|
|
379
|
+
* Once called, logixia's internal log pipeline checks for an active OTel span
|
|
380
|
+
* on **every** log call and automatically merges the span context into the
|
|
381
|
+
* entry's metadata — no per-call wiring needed.
|
|
382
|
+
*
|
|
383
|
+
* Call once at app startup, **after** the OTel SDK has been initialised:
|
|
384
|
+
* ```ts
|
|
385
|
+
* import { initOtelBridge } from 'logixia';
|
|
386
|
+
* initOtelBridge();
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
function initOtelBridge(opts = {}) {
|
|
390
|
+
_bridgeOptions = opts;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* @internal
|
|
394
|
+
* Used by the core logger to inject OTel context when the bridge is active.
|
|
395
|
+
* Returns `{}` when the bridge is not initialised or no active span exists.
|
|
396
|
+
*/
|
|
397
|
+
function _getOtelPayloadIfEnabled() {
|
|
398
|
+
if (!_bridgeOptions) return {};
|
|
399
|
+
return getOtelMetaFields(_bridgeOptions);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Disable the OTel bridge (useful for tests).
|
|
403
|
+
*/
|
|
404
|
+
function disableOtelBridge() {
|
|
405
|
+
_bridgeOptions = null;
|
|
406
|
+
}
|
|
407
|
+
|
|
217
408
|
//#endregion
|
|
218
409
|
//#region src/utils/redact.utils.ts
|
|
219
410
|
const DEFAULT_CENSOR = "[REDACTED]";
|
|
220
411
|
/**
|
|
412
|
+
* Conservative patterns: tokens and secrets that should NEVER appear in logs.
|
|
413
|
+
* Applied when `autoDetect: true` or `autoDetect: 'conservative'`.
|
|
414
|
+
*/
|
|
415
|
+
const PII_CONSERVATIVE_PATTERNS = [
|
|
416
|
+
/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g,
|
|
417
|
+
/Bearer\s+[A-Za-z0-9._~+/-]+=*/gi,
|
|
418
|
+
/\b(?:sk|pk|api|key|secret|token)-[A-Za-z0-9_-]{16,}/gi,
|
|
419
|
+
/\bAKIA[0-9A-Z]{16}\b/g,
|
|
420
|
+
/\b[A-Za-z0-9/+]{40}\b(?=.*aws)/gi
|
|
421
|
+
];
|
|
422
|
+
/**
|
|
423
|
+
* Conservative field-name paths auto-redacted by name regardless of value.
|
|
424
|
+
*/
|
|
425
|
+
const PII_CONSERVATIVE_PATHS = [
|
|
426
|
+
"**.password",
|
|
427
|
+
"**.passwd",
|
|
428
|
+
"**.secret",
|
|
429
|
+
"**.token",
|
|
430
|
+
"**.apiKey",
|
|
431
|
+
"**.api_key",
|
|
432
|
+
"**.accessToken",
|
|
433
|
+
"**.access_token",
|
|
434
|
+
"**.refreshToken",
|
|
435
|
+
"**.refresh_token",
|
|
436
|
+
"**.authorization",
|
|
437
|
+
"**.credentials",
|
|
438
|
+
"**.privateKey",
|
|
439
|
+
"**.private_key",
|
|
440
|
+
"**.clientSecret",
|
|
441
|
+
"**.client_secret"
|
|
442
|
+
];
|
|
443
|
+
/**
|
|
444
|
+
* Aggressive patterns: also catch personal data that could identify a person.
|
|
445
|
+
* Applied when `autoDetect: 'aggressive'`.
|
|
446
|
+
*/
|
|
447
|
+
const PII_AGGRESSIVE_PATTERNS = [
|
|
448
|
+
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
449
|
+
/\b\d{3}-?\d{2}-?\d{4}\b/g,
|
|
450
|
+
/\b(?:\d[ -]?){13,19}\b/g,
|
|
451
|
+
/\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g,
|
|
452
|
+
/\b(?:\d{1,3}\.){3}\d{1,3}\b/g
|
|
453
|
+
];
|
|
454
|
+
const PII_AGGRESSIVE_PATHS = [
|
|
455
|
+
...PII_CONSERVATIVE_PATHS,
|
|
456
|
+
"**.email",
|
|
457
|
+
"**.emailAddress",
|
|
458
|
+
"**.email_address",
|
|
459
|
+
"**.phone",
|
|
460
|
+
"**.phoneNumber",
|
|
461
|
+
"**.phone_number",
|
|
462
|
+
"**.mobile",
|
|
463
|
+
"**.ssn",
|
|
464
|
+
"**.sin",
|
|
465
|
+
"**.dob",
|
|
466
|
+
"**.dateOfBirth",
|
|
467
|
+
"**.date_of_birth",
|
|
468
|
+
"**.creditCard",
|
|
469
|
+
"**.credit_card",
|
|
470
|
+
"**.cardNumber",
|
|
471
|
+
"**.card_number",
|
|
472
|
+
"**.cvv",
|
|
473
|
+
"**.cvc",
|
|
474
|
+
"**.ipAddress",
|
|
475
|
+
"**.ip_address"
|
|
476
|
+
];
|
|
477
|
+
/**
|
|
478
|
+
* Build an effective config that merges `autoDetect` PII rules into the
|
|
479
|
+
* explicit `paths` and `patterns` the caller provided.
|
|
480
|
+
*/
|
|
481
|
+
function resolveConfig(config) {
|
|
482
|
+
const { autoDetect } = config;
|
|
483
|
+
if (!autoDetect) return config;
|
|
484
|
+
const aggressive = autoDetect === "aggressive";
|
|
485
|
+
const extraPaths = aggressive ? PII_AGGRESSIVE_PATHS : PII_CONSERVATIVE_PATHS;
|
|
486
|
+
const extraPatterns = aggressive ? [...PII_CONSERVATIVE_PATTERNS, ...PII_AGGRESSIVE_PATTERNS] : PII_CONSERVATIVE_PATTERNS;
|
|
487
|
+
const { paths = [], patterns = [] } = config;
|
|
488
|
+
return {
|
|
489
|
+
...config,
|
|
490
|
+
paths: [...paths, ...extraPaths],
|
|
491
|
+
patterns: [...patterns, ...extraPatterns]
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
221
495
|
* Convert a dot-notation path pattern to a RegExp.
|
|
222
496
|
* Supports `*` (one segment) and `**` (zero or more segments).
|
|
223
497
|
*
|
|
@@ -289,8 +563,9 @@ function redactObject(obj, config, _currentPath = "") {
|
|
|
289
563
|
*/
|
|
290
564
|
function applyRedaction(payload, config) {
|
|
291
565
|
if (!payload || !config) return payload;
|
|
292
|
-
|
|
293
|
-
|
|
566
|
+
const resolved$1 = resolveConfig(config);
|
|
567
|
+
if ((!resolved$1.paths || resolved$1.paths.length === 0) && (!resolved$1.patterns || resolved$1.patterns.length === 0)) return payload;
|
|
568
|
+
return redactObject(payload, resolved$1);
|
|
294
569
|
}
|
|
295
570
|
function isPlainObject(value) {
|
|
296
571
|
return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Error) && !(value instanceof RegExp);
|
|
@@ -666,11 +941,17 @@ function namespacePatternToRegex(pattern) {
|
|
|
666
941
|
const escaped = pattern.split(".").map((s) => s === "*" ? "[^.]+" : s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("\\.");
|
|
667
942
|
return /* @__PURE__ */ new RegExp(`^${escaped}$`);
|
|
668
943
|
}
|
|
944
|
+
/** Max compiled patterns to keep in memory. Oldest entry is evicted when full. */
|
|
945
|
+
const _NS_CACHE_MAX = 1e3;
|
|
669
946
|
const _nsPatternCache = /* @__PURE__ */ new Map();
|
|
670
947
|
function matchesNamespacePattern(ns, pattern) {
|
|
671
948
|
let re = _nsPatternCache.get(pattern);
|
|
672
949
|
if (!re) {
|
|
673
950
|
re = namespacePatternToRegex(pattern);
|
|
951
|
+
if (_nsPatternCache.size >= _NS_CACHE_MAX) {
|
|
952
|
+
const firstKey = _nsPatternCache.keys().next().value;
|
|
953
|
+
if (firstKey !== void 0) _nsPatternCache.delete(firstKey);
|
|
954
|
+
}
|
|
674
955
|
_nsPatternCache.set(pattern, re);
|
|
675
956
|
}
|
|
676
957
|
return re.test(ns);
|
|
@@ -701,6 +982,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
701
982
|
this._formattedLevels = /* @__PURE__ */ new Map();
|
|
702
983
|
this._formattedAppName = "";
|
|
703
984
|
this._hasRedact = false;
|
|
985
|
+
this._pluginRegistry = new PluginRegistry();
|
|
704
986
|
this.config = {
|
|
705
987
|
appName: "App",
|
|
706
988
|
environment: "development",
|
|
@@ -757,6 +1039,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
757
1039
|
});
|
|
758
1040
|
this.setupGracefulShutdown();
|
|
759
1041
|
this.createCustomLevelMethods();
|
|
1042
|
+
for (const p of globalPluginRegistry._plugins) this._pluginRegistry.register(p);
|
|
760
1043
|
this._buildPerfCaches();
|
|
761
1044
|
}
|
|
762
1045
|
setupGracefulShutdown() {
|
|
@@ -983,6 +1266,29 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
983
1266
|
};
|
|
984
1267
|
return childLogger;
|
|
985
1268
|
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Register a plugin on this logger instance.
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
* ```ts
|
|
1274
|
+
* logger.use({
|
|
1275
|
+
* name: 'audit',
|
|
1276
|
+
* onLog(entry) { auditQueue.push(entry); return entry; },
|
|
1277
|
+
* });
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
use(plugin) {
|
|
1281
|
+
this._pluginRegistry.register(plugin);
|
|
1282
|
+
return this;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Remove a previously registered plugin by name.
|
|
1286
|
+
* No-op if the plugin is not registered on this instance.
|
|
1287
|
+
*/
|
|
1288
|
+
unuse(pluginName) {
|
|
1289
|
+
this._pluginRegistry.unregister(pluginName);
|
|
1290
|
+
return this;
|
|
1291
|
+
}
|
|
986
1292
|
async flush() {
|
|
987
1293
|
if (this.transportManager) await this.transportManager.flush();
|
|
988
1294
|
}
|
|
@@ -1005,6 +1311,7 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1005
1311
|
await this.transportManager.close();
|
|
1006
1312
|
}
|
|
1007
1313
|
(_this$_sampler = this._sampler) === null || _this$_sampler === void 0 || _this$_sampler.destroy();
|
|
1314
|
+
await this._pluginRegistry.runOnShutdown();
|
|
1008
1315
|
deregisterFromShutdown(this);
|
|
1009
1316
|
}
|
|
1010
1317
|
async log(level, message, data) {
|
|
@@ -1015,10 +1322,19 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1015
1322
|
if (!this._sampler.shouldEmit(level, traceId$1)) return;
|
|
1016
1323
|
}
|
|
1017
1324
|
const alsContext = LogixiaContext.get();
|
|
1018
|
-
const
|
|
1325
|
+
const otelFields = _getOtelPayloadIfEnabled();
|
|
1326
|
+
const hasOtel = Object.keys(otelFields).length > 0;
|
|
1327
|
+
let mergedData;
|
|
1328
|
+
if (alsContext && Object.keys(alsContext).length > 0) mergedData = {
|
|
1019
1329
|
...alsContext,
|
|
1330
|
+
...hasOtel ? otelFields : {},
|
|
1020
1331
|
...data
|
|
1021
|
-
}
|
|
1332
|
+
};
|
|
1333
|
+
else if (hasOtel) mergedData = {
|
|
1334
|
+
...otelFields,
|
|
1335
|
+
...data
|
|
1336
|
+
};
|
|
1337
|
+
else mergedData = data;
|
|
1022
1338
|
const rawPayload = this._hasContextData ? {
|
|
1023
1339
|
...this.contextData,
|
|
1024
1340
|
...mergedData
|
|
@@ -1036,8 +1352,13 @@ var LogixiaLogger = class LogixiaLogger {
|
|
|
1036
1352
|
if (this.context) entry.context = this.context;
|
|
1037
1353
|
if (payload !== void 0) entry.payload = payload;
|
|
1038
1354
|
if (traceId !== void 0) entry.traceId = traceId;
|
|
1039
|
-
|
|
1040
|
-
|
|
1355
|
+
let finalEntry = entry;
|
|
1356
|
+
if (this._pluginRegistry.size > 0) {
|
|
1357
|
+
finalEntry = await this._pluginRegistry.runOnLog(entry);
|
|
1358
|
+
if (finalEntry === null) return;
|
|
1359
|
+
}
|
|
1360
|
+
const formattedLog = this.formatLog(finalEntry);
|
|
1361
|
+
await this.output(formattedLog, level, finalEntry);
|
|
1041
1362
|
}
|
|
1042
1363
|
/**
|
|
1043
1364
|
* Hot-path level check: a single Map lookup + integer compare.
|
|
@@ -10591,6 +10912,12 @@ Object.defineProperty(exports, 'LogixiaLoggerService', {
|
|
|
10591
10912
|
return LogixiaLoggerService;
|
|
10592
10913
|
}
|
|
10593
10914
|
});
|
|
10915
|
+
Object.defineProperty(exports, 'PluginRegistry', {
|
|
10916
|
+
enumerable: true,
|
|
10917
|
+
get: function () {
|
|
10918
|
+
return PluginRegistry;
|
|
10919
|
+
}
|
|
10920
|
+
});
|
|
10594
10921
|
Object.defineProperty(exports, 'TraceMiddleware', {
|
|
10595
10922
|
enumerable: true,
|
|
10596
10923
|
get: function () {
|
|
@@ -10603,6 +10930,18 @@ Object.defineProperty(exports, 'WebSocketTraceInterceptor', {
|
|
|
10603
10930
|
return WebSocketTraceInterceptor;
|
|
10604
10931
|
}
|
|
10605
10932
|
});
|
|
10933
|
+
Object.defineProperty(exports, '__decorate', {
|
|
10934
|
+
enumerable: true,
|
|
10935
|
+
get: function () {
|
|
10936
|
+
return __decorate;
|
|
10937
|
+
}
|
|
10938
|
+
});
|
|
10939
|
+
Object.defineProperty(exports, '__decorateMetadata', {
|
|
10940
|
+
enumerable: true,
|
|
10941
|
+
get: function () {
|
|
10942
|
+
return __decorateMetadata;
|
|
10943
|
+
}
|
|
10944
|
+
});
|
|
10606
10945
|
Object.defineProperty(exports, 'applyRedaction', {
|
|
10607
10946
|
enumerable: true,
|
|
10608
10947
|
get: function () {
|
|
@@ -10639,6 +10978,12 @@ Object.defineProperty(exports, 'deregisterFromShutdown', {
|
|
|
10639
10978
|
return deregisterFromShutdown;
|
|
10640
10979
|
}
|
|
10641
10980
|
});
|
|
10981
|
+
Object.defineProperty(exports, 'disableOtelBridge', {
|
|
10982
|
+
enumerable: true,
|
|
10983
|
+
get: function () {
|
|
10984
|
+
return disableOtelBridge;
|
|
10985
|
+
}
|
|
10986
|
+
});
|
|
10642
10987
|
Object.defineProperty(exports, 'extractTraceId', {
|
|
10643
10988
|
enumerable: true,
|
|
10644
10989
|
get: function () {
|
|
@@ -10657,12 +11002,36 @@ Object.defineProperty(exports, 'generateTraceId', {
|
|
|
10657
11002
|
return generateTraceId;
|
|
10658
11003
|
}
|
|
10659
11004
|
});
|
|
11005
|
+
Object.defineProperty(exports, 'getActiveOtelContext', {
|
|
11006
|
+
enumerable: true,
|
|
11007
|
+
get: function () {
|
|
11008
|
+
return getActiveOtelContext;
|
|
11009
|
+
}
|
|
11010
|
+
});
|
|
10660
11011
|
Object.defineProperty(exports, 'getCurrentTraceId', {
|
|
10661
11012
|
enumerable: true,
|
|
10662
11013
|
get: function () {
|
|
10663
11014
|
return getCurrentTraceId;
|
|
10664
11015
|
}
|
|
10665
11016
|
});
|
|
11017
|
+
Object.defineProperty(exports, 'getOtelMetaFields', {
|
|
11018
|
+
enumerable: true,
|
|
11019
|
+
get: function () {
|
|
11020
|
+
return getOtelMetaFields;
|
|
11021
|
+
}
|
|
11022
|
+
});
|
|
11023
|
+
Object.defineProperty(exports, 'globalPluginRegistry', {
|
|
11024
|
+
enumerable: true,
|
|
11025
|
+
get: function () {
|
|
11026
|
+
return globalPluginRegistry;
|
|
11027
|
+
}
|
|
11028
|
+
});
|
|
11029
|
+
Object.defineProperty(exports, 'initOtelBridge', {
|
|
11030
|
+
enumerable: true,
|
|
11031
|
+
get: function () {
|
|
11032
|
+
return initOtelBridge;
|
|
11033
|
+
}
|
|
11034
|
+
});
|
|
10666
11035
|
Object.defineProperty(exports, 'isError', {
|
|
10667
11036
|
enumerable: true,
|
|
10668
11037
|
get: function () {
|
|
@@ -10717,4 +11086,10 @@ Object.defineProperty(exports, 'traceStorage', {
|
|
|
10717
11086
|
return traceStorage;
|
|
10718
11087
|
}
|
|
10719
11088
|
});
|
|
10720
|
-
|
|
11089
|
+
Object.defineProperty(exports, 'usePlugin', {
|
|
11090
|
+
enumerable: true,
|
|
11091
|
+
get: function () {
|
|
11092
|
+
return usePlugin;
|
|
11093
|
+
}
|
|
11094
|
+
});
|
|
11095
|
+
//# sourceMappingURL=logitron-logger.module-CCnX7GwK.js.map
|