logixia 1.13.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -44
- package/dist/async-context-B05ArHgM.mjs +134 -0
- package/dist/async-context-B05ArHgM.mjs.map +1 -0
- package/dist/async-context-DTQgi8f7.js +150 -0
- package/dist/async-context-DTQgi8f7.js.map +1 -0
- package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
- package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
- package/dist/{azure-monitor.transport-BDFO4F-i.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
- package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
- package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
- package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
- package/dist/{azure-monitor.transport-D5wQEH04.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
- package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
- package/dist/azure.d.mts +1 -2
- package/dist/azure.d.ts +1 -2
- package/dist/azure.js +3 -6
- package/dist/azure.mjs +1 -6
- package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
- package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
- package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
- package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
- package/dist/browser.d.mts +52 -23
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +52 -23
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +460 -62
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +461 -65
- package/dist/browser.mjs.map +1 -1
- package/dist/{nestjs-extras-ImbuDhs1.mjs → builder-D70z6kjj.mjs} +279 -965
- package/dist/builder-D70z6kjj.mjs.map +1 -0
- package/dist/{nestjs-extras-DnJ6vrIC.js → builder-M7NoaugM.js} +421 -1177
- package/dist/builder-M7NoaugM.js.map +1 -0
- package/dist/cli/index.js +86 -67
- package/dist/cloudwatch.d.mts +1 -2
- package/dist/cloudwatch.d.ts +1 -2
- package/dist/cloudwatch.js +3 -7
- package/dist/cloudwatch.mjs +1 -7
- package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
- package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
- package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
- package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
- package/dist/{cloudwatch.transport-B00st6Xv.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
- package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-Blc7Gtxt.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
- package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
- package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
- package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
- package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
- package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
- package/dist/correlation.d.mts +13 -16
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +13 -16
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +58 -9
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +56 -6
- package/dist/correlation.mjs.map +1 -1
- package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
- package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
- package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
- package/dist/entry-fields-RLd1jCoR.js.map +1 -0
- package/dist/gcp.d.mts +1 -2
- package/dist/gcp.d.ts +1 -2
- package/dist/gcp.js +3 -7
- package/dist/gcp.mjs +1 -7
- package/dist/{gcp.transport-m4fVw0b1.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
- package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
- package/dist/{gcp.transport-zzNyIoih.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
- package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
- package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
- package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
- package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
- package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
- package/dist/{index-nZEeCr3X.d.ts → index-DwozbmB4.d.ts} +3 -8
- package/dist/index-DwozbmB4.d.ts.map +1 -0
- package/dist/{index-BPwEisy4.d.mts → index-xqaJtAZn.d.mts} +3 -8
- package/dist/index-xqaJtAZn.d.mts.map +1 -0
- package/dist/index.d.mts +141 -203
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +140 -202
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +196 -381
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -294
- package/dist/index.mjs.map +1 -1
- package/dist/internal-log-b0Vp4qrB.js +183 -0
- package/dist/internal-log-b0Vp4qrB.js.map +1 -0
- package/dist/internal-log-uCSd1PMc.mjs +142 -0
- package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts +365 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts +365 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
- package/dist/middleware.d.mts +10 -12
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +10 -12
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +16 -47
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +13 -45
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +467 -10
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +467 -10
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +889 -43
- package/dist/nest.js.map +1 -0
- package/dist/nest.mjs +850 -9
- package/dist/nest.mjs.map +1 -0
- package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
- package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
- package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
- package/dist/request-trace-wTJdKp6-.js.map +1 -0
- package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
- package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
- package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
- package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
- package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
- package/dist/{search-CHUZPl0h.d.ts → search-BH33XhuU.d.mts} +2 -22
- package/dist/search-BH33XhuU.d.mts.map +1 -0
- package/dist/{search-DjXSn6v5.mjs → search-CWMVYC-R.mjs} +34 -41
- package/dist/search-CWMVYC-R.mjs.map +1 -0
- package/dist/{search-BfBzDIT9.d.mts → search-CazwyX5Z.d.ts} +2 -22
- package/dist/search-CazwyX5Z.d.ts.map +1 -0
- package/dist/{search-B0MH1SJJ.js → search-DUfWuzFP.js} +64 -71
- package/dist/search-DUfWuzFP.js.map +1 -0
- package/dist/search.d.mts +2 -4
- package/dist/search.d.ts +2 -4
- package/dist/search.js +3 -4
- package/dist/search.mjs +1 -4
- package/dist/secret-config-BegMLkYl.mjs +209 -0
- package/dist/secret-config-BegMLkYl.mjs.map +1 -0
- package/dist/secret-config-CBZBs0p1.js +271 -0
- package/dist/secret-config-CBZBs0p1.js.map +1 -0
- package/dist/slack.transport-Ce96JBDk.mjs +824 -0
- package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
- package/dist/slack.transport-Dlx3xvb7.js +847 -0
- package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
- package/dist/slack.transport-DrirgDNy.d.ts +159 -0
- package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
- package/dist/slack.transport-DxHOXlLu.d.mts +159 -0
- package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
- package/dist/testing.d.mts +3 -8
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.d.ts +3 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -4
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +2 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.manager-Crau3Rle.js → transport.manager-DkcEOlqV.js} +331 -234
- package/dist/transport.manager-DkcEOlqV.js.map +1 -0
- package/dist/{transport.manager-CpdVHEGP.mjs → transport.manager-eZ_EeC00.mjs} +274 -178
- package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
- package/dist/{transport.types-CtNr3D7S.d.mts → transport.types-BJVL1QQl.d.mts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
- package/dist/{transport.types-DqVLZTyf.d.ts → transport.types-BJVL1QQl.d.ts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
- package/dist/transports.d.mts +32 -41
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +32 -41
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +12 -12
- package/dist/transports.mjs +7 -12
- package/dist/worker-entry.js +337 -87
- package/dist/worker.d.mts +1 -2
- package/dist/worker.d.ts +1 -2
- package/dist/worker.js +3 -4
- package/dist/worker.mjs +1 -4
- package/dist/{worker.transport-Bj-i0P9V.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
- package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
- package/dist/{worker.transport-JP8YHBuU.js → worker.transport-C6GNl_r2.js} +44 -14
- package/dist/worker.transport-C6GNl_r2.js.map +1 -0
- package/dist/{worker.transport-otwhJ_Et.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
- package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
- package/dist/{worker.transport-Bgv9heDI.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
- package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
- package/package.json +36 -19
- package/dist/async-context-BzJrbfQs.mjs +0 -72
- package/dist/async-context-BzJrbfQs.mjs.map +0 -1
- package/dist/async-context-DyQQYq3I.js +0 -92
- package/dist/async-context-DyQQYq3I.js.map +0 -1
- package/dist/azure-monitor.transport-BDFO4F-i.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D5wQEH04.d.mts.map +0 -1
- package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
- package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-B00st6Xv.d.ts.map +0 -1
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-Blc7Gtxt.d.mts.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
- package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
- package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
- package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
- package/dist/gcp.transport-m4fVw0b1.d.ts.map +0 -1
- package/dist/gcp.transport-zzNyIoih.d.mts.map +0 -1
- package/dist/index-BPwEisy4.d.mts.map +0 -1
- package/dist/index-nZEeCr3X.d.ts.map +0 -1
- package/dist/internal-log-BUJYMZbE.js +0 -70
- package/dist/internal-log-BUJYMZbE.js.map +0 -1
- package/dist/internal-log-Cm8SOWSV.mjs +0 -52
- package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
- package/dist/nestjs-extras-DnJ6vrIC.js.map +0 -1
- package/dist/nestjs-extras-ImbuDhs1.mjs.map +0 -1
- package/dist/nestjs-extras-OkC796py.d.mts +0 -725
- package/dist/nestjs-extras-OkC796py.d.mts.map +0 -1
- package/dist/nestjs-extras-mKrHE9S6.d.ts +0 -725
- package/dist/nestjs-extras-mKrHE9S6.d.ts.map +0 -1
- package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
- package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
- package/dist/search-B0MH1SJJ.js.map +0 -1
- package/dist/search-BfBzDIT9.d.mts.map +0 -1
- package/dist/search-CHUZPl0h.d.ts.map +0 -1
- package/dist/search-DjXSn6v5.mjs.map +0 -1
- package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
- package/dist/trace.utils-DpBOLDtq.js.map +0 -1
- package/dist/transport.manager-CpdVHEGP.mjs.map +0 -1
- package/dist/transport.manager-Crau3Rle.js.map +0 -1
- package/dist/transport.types-CtNr3D7S.d.mts.map +0 -1
- package/dist/transport.types-DqVLZTyf.d.ts.map +0 -1
- package/dist/worker.transport-Bgv9heDI.d.mts.map +0 -1
- package/dist/worker.transport-Bj-i0P9V.d.ts.map +0 -1
- package/dist/worker.transport-JP8YHBuU.js.map +0 -1
- package/dist/worker.transport-otwhJ_Et.mjs.map +0 -1
|
@@ -1,725 +0,0 @@
|
|
|
1
|
-
import { E as TraceIdConfig, b as LoggerWithLevels, f as ILogger, h as LogEntry, p as ILoggerDefault, v as LogLevelString, x as NamespaceLevels, y as LoggerConfig } from "./index-BPwEisy4.mjs";
|
|
2
|
-
import * as _nestjs_common0 from "@nestjs/common";
|
|
3
|
-
import { ArgumentsHost, CallHandler, ExceptionFilter, ExecutionContext, InjectionToken, LoggerService, MiddlewareConsumer, ModuleMetadata, NestInterceptor, NestModule, OptionalFactoryDependency, Type } from "@nestjs/common";
|
|
4
|
-
import { Observable } from "rxjs";
|
|
5
|
-
|
|
6
|
-
//#region src/plugin.d.ts
|
|
7
|
-
|
|
8
|
-
interface LogixiaPlugin {
|
|
9
|
-
/**
|
|
10
|
-
* Unique plugin name.
|
|
11
|
-
* logixia uses this to prevent duplicate registration of the same plugin
|
|
12
|
-
* on the same logger instance.
|
|
13
|
-
*/
|
|
14
|
-
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Called once immediately after `logger.use(plugin)` is called.
|
|
17
|
-
* Use for one-time setup (open connections, allocate buffers, etc.).
|
|
18
|
-
* Async `onInit` errors are silently swallowed to avoid blocking the logger.
|
|
19
|
-
*/
|
|
20
|
-
onInit?(): void | Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Called for every log entry **after** PII redaction and **before** transport
|
|
23
|
-
* dispatch. Plugins run in registration order; each receives the (possibly
|
|
24
|
-
* modified) output of the previous plugin.
|
|
25
|
-
*
|
|
26
|
-
* - Return the entry (modified or unchanged) to continue processing.
|
|
27
|
-
* - Return `null` to **drop** the entry — no transport will receive it.
|
|
28
|
-
*
|
|
29
|
-
* Errors thrown inside `onLog` are swallowed so a buggy plugin cannot crash
|
|
30
|
-
* logging; the chain continues with the previous (un-transformed) entry.
|
|
31
|
-
*/
|
|
32
|
-
onLog?(entry: LogEntry): LogEntry | null | Promise<LogEntry | null>;
|
|
33
|
-
/**
|
|
34
|
-
* Called when a transport write fails (after any configured retries).
|
|
35
|
-
* Useful for routing transport errors to an alerting or metrics system.
|
|
36
|
-
* Errors thrown inside `onError` are silently swallowed.
|
|
37
|
-
*/
|
|
38
|
-
onError?(error: Error, entry?: LogEntry): void | Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Called when the logger is closed via `logger.close()` or the process
|
|
41
|
-
* receives a shutdown signal (when `gracefulShutdown` is enabled).
|
|
42
|
-
* Errors thrown inside `onShutdown` are silently swallowed.
|
|
43
|
-
*/
|
|
44
|
-
onShutdown?(): void | Promise<void>;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Holds an ordered list of `LogixiaPlugin` instances and dispatches lifecycle
|
|
48
|
-
* events to them. One registry is created per logger instance; a global
|
|
49
|
-
* singleton is also exported for process-wide registration.
|
|
50
|
-
*/
|
|
51
|
-
declare class PluginRegistry {
|
|
52
|
-
private readonly _plugins;
|
|
53
|
-
/**
|
|
54
|
-
* Register a plugin. Silently skips if a plugin with the same `name` is
|
|
55
|
-
* already registered on this registry.
|
|
56
|
-
*/
|
|
57
|
-
register(plugin: LogixiaPlugin): void;
|
|
58
|
-
/** Remove a previously registered plugin by name. No-op if not found. */
|
|
59
|
-
unregister(name: string): void;
|
|
60
|
-
/** Returns `true` if a plugin with the given name is registered. */
|
|
61
|
-
has(name: string): boolean;
|
|
62
|
-
/** Number of currently registered plugins. */
|
|
63
|
-
get size(): number;
|
|
64
|
-
/**
|
|
65
|
-
* Run all `onLog` hooks in order.
|
|
66
|
-
* Returns `null` if any plugin cancels the entry; otherwise returns the
|
|
67
|
-
* (possibly transformed) entry.
|
|
68
|
-
*/
|
|
69
|
-
runOnLog(entry: LogEntry): Promise<LogEntry | null>;
|
|
70
|
-
/**
|
|
71
|
-
* Notify all `onError` hooks.
|
|
72
|
-
* Errors thrown inside hooks are swallowed to prevent error cascades.
|
|
73
|
-
*/
|
|
74
|
-
runOnError(error: Error, entry?: LogEntry): Promise<void>;
|
|
75
|
-
/** Run all `onShutdown` hooks concurrently. Hook errors are swallowed. */
|
|
76
|
-
runOnShutdown(): Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Module-level singleton registry.
|
|
80
|
-
*
|
|
81
|
-
* Plugins registered here are automatically copied into every **new** logger
|
|
82
|
-
* instance created after the registration. Already-created loggers are not
|
|
83
|
-
* retroactively affected — use `logger.use(plugin)` for per-instance control.
|
|
84
|
-
*/
|
|
85
|
-
declare const globalPluginRegistry: PluginRegistry;
|
|
86
|
-
/**
|
|
87
|
-
* Register a plugin in the global registry so it applies to every future
|
|
88
|
-
* logger instance.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* import { usePlugin } from 'logixia';
|
|
93
|
-
*
|
|
94
|
-
* usePlugin({
|
|
95
|
-
* name: 'audit-sink',
|
|
96
|
-
* onLog(entry) {
|
|
97
|
-
* if (entry.level === 'error') auditQueue.push(entry);
|
|
98
|
-
* return entry;
|
|
99
|
-
* },
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
declare function usePlugin(plugin: LogixiaPlugin): void;
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region src/core/logitron-logger.d.ts
|
|
106
|
-
declare class LogixiaLogger<TConfig extends LoggerConfig<Record<string, number>> = LoggerConfig> implements ILoggerDefault {
|
|
107
|
-
[K: string]: any;
|
|
108
|
-
private config;
|
|
109
|
-
private context?;
|
|
110
|
-
private timers;
|
|
111
|
-
private contextData;
|
|
112
|
-
private transportManager;
|
|
113
|
-
private fieldState;
|
|
114
|
-
/** Stable fallback trace ID generated ONCE per logger instance. */
|
|
115
|
-
private readonly fallbackTraceId;
|
|
116
|
-
/** Numeric value for each known log level — built once, read on every log call. */
|
|
117
|
-
private _levelValues;
|
|
118
|
-
/** Numeric threshold for the currently active log level. */
|
|
119
|
-
private _minLevelValue;
|
|
120
|
-
/** `source=value` pairs already reported as unknown levels — warn once per logger. */
|
|
121
|
-
private readonly _warnedInvalidLevels;
|
|
122
|
-
/** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
|
|
123
|
-
private _colorMap;
|
|
124
|
-
/** Pre-computed field-enabled booleans so isFieldEnabled() isn't called per log. */
|
|
125
|
-
private _fieldCache;
|
|
126
|
-
/** True when contextData is non-empty — avoids Object.keys() check on hot path. */
|
|
127
|
-
private _hasContextData;
|
|
128
|
-
/**
|
|
129
|
-
* Pre-computed `[INFO] `, `[WARN] ` etc. strings — avoids a colorize() call per log.
|
|
130
|
-
* Key: lowercase level name. Value: formatted bracket string ready to concatenate.
|
|
131
|
-
*/
|
|
132
|
-
private _formattedLevels;
|
|
133
|
-
/** Pre-computed `[appName] ` string — avoids template literal allocation per log. */
|
|
134
|
-
private _formattedAppName;
|
|
135
|
-
/** True when a redact config is present — short-circuits applyRedaction when false. */
|
|
136
|
-
private _hasRedact;
|
|
137
|
-
/** Sampling engine — only created when sampling config is present. */
|
|
138
|
-
private _sampler;
|
|
139
|
-
/** Per-instance plugin registry — also inherits from the global registry at creation time. */
|
|
140
|
-
private readonly _pluginRegistry;
|
|
141
|
-
/** Set on loggers created by child(); they borrow the root's transports, sampler and plugins. */
|
|
142
|
-
private readonly _parent;
|
|
143
|
-
constructor(config: TConfig, context?: string, parent?: LogixiaLogger<TConfig>);
|
|
144
|
-
private setupGracefulShutdown;
|
|
145
|
-
private createCustomLevelMethods;
|
|
146
|
-
/**
|
|
147
|
-
* Rebuild all hot-path caches after any config mutation or level change.
|
|
148
|
-
* Keeps the actual log() call free of allocations in the common case.
|
|
149
|
-
*/
|
|
150
|
-
private _buildPerfCaches;
|
|
151
|
-
error(messageOrError: string | Error, data?: Record<string, unknown>): Promise<void>;
|
|
152
|
-
warn(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
153
|
-
info(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
154
|
-
debug(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
155
|
-
trace(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
156
|
-
verbose(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
157
|
-
logLevel(level: string, message: string, data?: Record<string, unknown>): Promise<void>;
|
|
158
|
-
time(label: string): void;
|
|
159
|
-
timeEnd(label: string): Promise<number | undefined>;
|
|
160
|
-
timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
|
|
161
|
-
setLevel(level: LogLevelString): void;
|
|
162
|
-
getLevel(): LogLevelString;
|
|
163
|
-
private _validLevelList;
|
|
164
|
-
/**
|
|
165
|
-
* Canonicalise a level from config/ENV. Unknown values return undefined so the
|
|
166
|
-
* caller falls through to the next source, and warn once per logger per source.
|
|
167
|
-
*/
|
|
168
|
-
private _validLevel;
|
|
169
|
-
/**
|
|
170
|
-
* Replace the per-namespace level map at runtime — no restart needed.
|
|
171
|
-
*
|
|
172
|
-
* This is the runtime counterpart to the `namespaceLevels` config option and
|
|
173
|
-
* the most-requested logging feature across the Winston/Pino issue trackers
|
|
174
|
-
* (flip a module's verbosity live to chase a bug without raising global
|
|
175
|
-
* volume). The new map fully replaces the previous one.
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```ts
|
|
179
|
-
* // Turn on debug for the DB layer only, live:
|
|
180
|
-
* logger.setNamespaceLevels({ 'db.*': 'debug', '*': 'info' });
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
setNamespaceLevels(levels: NamespaceLevels): void;
|
|
184
|
-
/** Merge entries into the existing per-namespace level map at runtime. */
|
|
185
|
-
patchNamespaceLevels(levels: NamespaceLevels): void;
|
|
186
|
-
/** Return a copy of the current per-namespace level map. */
|
|
187
|
-
getNamespaceLevels(): NamespaceLevels;
|
|
188
|
-
setContext(context: string): void;
|
|
189
|
-
getContext(): string | undefined;
|
|
190
|
-
enableField(fieldName: string): void;
|
|
191
|
-
disableField(fieldName: string): void;
|
|
192
|
-
isFieldEnabled(fieldName: string): boolean;
|
|
193
|
-
getFieldState(): Record<string, boolean>;
|
|
194
|
-
resetFieldState(): void;
|
|
195
|
-
/** @deprecated No-op. Library code never prompts on stdin; use setTransportLevels(). */
|
|
196
|
-
enableTransportLevelPrompting(): void;
|
|
197
|
-
/** @deprecated No-op. */
|
|
198
|
-
disableTransportLevelPrompting(): void;
|
|
199
|
-
setTransportLevels(transportId: string, levels: string[]): void;
|
|
200
|
-
getTransportLevels(transportId: string): string[] | undefined;
|
|
201
|
-
clearTransportLevelPreferences(): void;
|
|
202
|
-
getAvailableTransports(): string[];
|
|
203
|
-
child(context: string, data?: Record<string, unknown>): ILogger;
|
|
204
|
-
/**
|
|
205
|
-
* Register a plugin on this logger instance.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```ts
|
|
209
|
-
* logger.use({
|
|
210
|
-
* name: 'audit',
|
|
211
|
-
* onLog(entry) { auditQueue.push(entry); return entry; },
|
|
212
|
-
* });
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
use(plugin: LogixiaPlugin): this;
|
|
216
|
-
/**
|
|
217
|
-
* Remove a previously registered plugin by name.
|
|
218
|
-
* No-op if the plugin is not registered on this instance.
|
|
219
|
-
*/
|
|
220
|
-
unuse(pluginName: string): this;
|
|
221
|
-
flush(): Promise<void>;
|
|
222
|
-
healthCheck(): Promise<{
|
|
223
|
-
healthy: boolean;
|
|
224
|
-
details: Record<string, unknown>;
|
|
225
|
-
}>;
|
|
226
|
-
close(): Promise<void>;
|
|
227
|
-
private log;
|
|
228
|
-
/**
|
|
229
|
-
* Hot-path level check: a single Map lookup + integer compare.
|
|
230
|
-
* The level map and threshold are pre-built in _buildPerfCaches().
|
|
231
|
-
*/
|
|
232
|
-
private shouldLog;
|
|
233
|
-
/**
|
|
234
|
-
* Feature 3: Resolve the effective log level for this logger instance.
|
|
235
|
-
*
|
|
236
|
-
* Priority:
|
|
237
|
-
* 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
|
|
238
|
-
* 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
|
|
239
|
-
* 3. Global `LOGIXIA_LEVEL` ENV override
|
|
240
|
-
* 4. `levelOptions.level` (resolved via Feature 5 in constructor)
|
|
241
|
-
*/
|
|
242
|
-
private resolveEffectiveLevel;
|
|
243
|
-
private formatLog;
|
|
244
|
-
private colorize;
|
|
245
|
-
/**
|
|
246
|
-
* Dispatch the entry to transports (each formats itself). Returns `void` when
|
|
247
|
-
* the write completes synchronously (console-only hot path) and a Promise only
|
|
248
|
-
* when a transport is genuinely async — so the caller awaits only when needed.
|
|
249
|
-
* Formatting for the no-transport fallback is done lazily, never on the
|
|
250
|
-
* transport path.
|
|
251
|
-
*/
|
|
252
|
-
private output;
|
|
253
|
-
/** Shared transport-failure handler: log internally, notify plugins, then fall
|
|
254
|
-
* back to a direct stdout/stderr write so the entry is never lost. */
|
|
255
|
-
private _handleOutputError;
|
|
256
|
-
}
|
|
257
|
-
declare function createLogger<T extends LoggerConfig<Record<string, number>>>(config: T, context?: string): LoggerWithLevels<T>;
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/core/logitron-nestjs.service.d.ts
|
|
260
|
-
/**
|
|
261
|
-
* Level names that already have proper typed implementations on LogixiaLoggerService.
|
|
262
|
-
* These are excluded from the auto-generated method type so we don't produce
|
|
263
|
-
* duplicate / conflicting signatures.
|
|
264
|
-
*/
|
|
265
|
-
type _ServiceBuiltinLevels = 'error' | 'warn' | 'info' | 'debug' | 'verbose' | 'trace' | 'log' | 'logLevel';
|
|
266
|
-
/**
|
|
267
|
-
* Mapped type that adds one method per *custom* level (i.e. every key in TLevels
|
|
268
|
-
* that is not already a built-in method on LogixiaLoggerService).
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ServiceCustomLevelMethods<{ kafka: 3; mysql: 4; payment: 5 }>
|
|
272
|
-
* // → { kafka(msg, data?): Promise<void>; mysql(...): …; payment(...): … }
|
|
273
|
-
*/
|
|
274
|
-
type ServiceCustomLevelMethods<TLevels extends Record<string, number>> = { readonly [K in keyof TLevels as K extends _ServiceBuiltinLevels ? never : K & string]: (message: string, data?: Record<string, unknown>) => Promise<void> };
|
|
275
|
-
/**
|
|
276
|
-
* The return type of `LogixiaLoggerService.create<T>(config)`.
|
|
277
|
-
*
|
|
278
|
-
* When `T` carries `levelOptions.levels`, this type intersects
|
|
279
|
-
* `LogixiaLoggerService` with a method for every *custom* level so the IDE
|
|
280
|
-
* suggests `service.kafka(...)`, `service.payment(...)`, etc.
|
|
281
|
-
*/
|
|
282
|
-
type LogixiaServiceWithLevels<T extends LoggerConfig<Record<string, number>>> = T['levelOptions'] extends {
|
|
283
|
-
levels: infer L;
|
|
284
|
-
} ? L extends Record<string, number> ? LogixiaLoggerService & ServiceCustomLevelMethods<L> : LogixiaLoggerService : LogixiaLoggerService;
|
|
285
|
-
/**
|
|
286
|
-
* Helper — extracts custom level names from a config object's `levelOptions.levels`.
|
|
287
|
-
*/
|
|
288
|
-
type _ExtractCustomLevelNames<T> = T extends {
|
|
289
|
-
levelOptions?: {
|
|
290
|
-
levels?: infer L;
|
|
291
|
-
};
|
|
292
|
-
} ? L extends Record<string, number> ? Exclude<keyof L & string, _ServiceBuiltinLevels> : never : never;
|
|
293
|
-
/**
|
|
294
|
-
* Typed `LogixiaLoggerService` with autocomplete for custom levels.
|
|
295
|
-
*
|
|
296
|
-
* Accepts either:
|
|
297
|
-
* - **string union** of custom level names: `LogixiaServiceWith<'kafka' | 'payment'>`
|
|
298
|
-
* - **config object type** (via `typeof`): `LogixiaServiceWith<typeof logixiaConfig>`
|
|
299
|
-
*
|
|
300
|
-
* Define your config with `as const` once, derive the type everywhere:
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```ts
|
|
304
|
-
* // logger.config.ts — define once
|
|
305
|
-
* export const logixiaConfig = {
|
|
306
|
-
* levelOptions: {
|
|
307
|
-
* levels: { error: 0, warn: 1, info: 2, debug: 3, verbose: 4, kafka: 5, payment: 6 },
|
|
308
|
-
* },
|
|
309
|
-
* } as const;
|
|
310
|
-
* export type AppLogger = LogixiaServiceWith<typeof logixiaConfig>;
|
|
311
|
-
*
|
|
312
|
-
* // any.controller.ts — use everywhere, no casting
|
|
313
|
-
* constructor(private readonly logger: AppLogger) {}
|
|
314
|
-
* // this.logger.kafka('msg') ← fully typed
|
|
315
|
-
* // this.logger.payment('msg') ← fully typed
|
|
316
|
-
* ```
|
|
317
|
-
*
|
|
318
|
-
* @example
|
|
319
|
-
* ```ts
|
|
320
|
-
* // Or use string union directly:
|
|
321
|
-
* type AppLogger = LogixiaServiceWith<'kafka' | 'payment'>;
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
type LogixiaServiceWith<T extends string | Record<string, unknown>> = LogixiaLoggerService & { readonly [K in T extends string ? Exclude<T, _ServiceBuiltinLevels> : _ExtractCustomLevelNames<T>]: (message: string, data?: Record<string, unknown>) => Promise<void> };
|
|
325
|
-
declare class LogixiaLoggerService implements LoggerService {
|
|
326
|
-
[K: string]: any;
|
|
327
|
-
private logger;
|
|
328
|
-
private context?;
|
|
329
|
-
private _mergedConfig;
|
|
330
|
-
constructor(config?: LoggerConfig);
|
|
331
|
-
private _createCustomLevelMethods;
|
|
332
|
-
/**
|
|
333
|
-
* NestJS `LoggerService.log` — void, string context.
|
|
334
|
-
* Maps internally to `info`.
|
|
335
|
-
*
|
|
336
|
-
* @example `logger.log('User signed up', 'AuthService')`
|
|
337
|
-
*/
|
|
338
|
-
log(message: unknown, context?: string): void;
|
|
339
|
-
/**
|
|
340
|
-
* Native async `info` — structured data, returns `Promise<void>`.
|
|
341
|
-
*
|
|
342
|
-
* @example `await logger.info('User signed up', { userId: 'u_abc' })`
|
|
343
|
-
*/
|
|
344
|
-
info(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
345
|
-
/**
|
|
346
|
-
* Native async overload — structured metadata, returns `Promise<void>`.
|
|
347
|
-
*
|
|
348
|
-
* @example `await logger.error(new Error('DB timeout'), { requestId: 'req_abc' })`
|
|
349
|
-
* @example `await logger.error('Login failed', { userId: 'u_abc' })`
|
|
350
|
-
*/
|
|
351
|
-
error(message: string | Error, data: Record<string, unknown>): Promise<void>;
|
|
352
|
-
/**
|
|
353
|
-
* NestJS compat overload — string trace + optional context, returns `void`.
|
|
354
|
-
*
|
|
355
|
-
* @example `logger.error('Something failed', err.stack, 'AuthService')`
|
|
356
|
-
*/
|
|
357
|
-
error(message: unknown, trace?: string, context?: string): void;
|
|
358
|
-
/**
|
|
359
|
-
* Native async overload — structured metadata, returns `Promise<void>`.
|
|
360
|
-
*
|
|
361
|
-
* @example `await logger.warn('Rate limit approaching', { userId: 'u_abc', count: 90 })`
|
|
362
|
-
*/
|
|
363
|
-
warn(message: string, data: Record<string, unknown>): Promise<void>;
|
|
364
|
-
/**
|
|
365
|
-
* NestJS compat overload — optional context string, returns `void`.
|
|
366
|
-
*
|
|
367
|
-
* @example `logger.warn('Deprecated API used', 'PaymentService')`
|
|
368
|
-
*/
|
|
369
|
-
warn(message: unknown, context?: string): void;
|
|
370
|
-
/**
|
|
371
|
-
* Native async overload — structured metadata, returns `Promise<void>`.
|
|
372
|
-
*
|
|
373
|
-
* @example `await logger.debug('Cache miss', { key: 'user:abc', ttl: 300 })`
|
|
374
|
-
*/
|
|
375
|
-
debug(message: string, data: Record<string, unknown>): Promise<void>;
|
|
376
|
-
/**
|
|
377
|
-
* NestJS compat overload — optional context string, returns `void`.
|
|
378
|
-
*
|
|
379
|
-
* @example `logger.debug('Processing request', 'OrderService')`
|
|
380
|
-
*/
|
|
381
|
-
debug(message: unknown, context?: string): void;
|
|
382
|
-
/**
|
|
383
|
-
* Native async overload — structured metadata, returns `Promise<void>`.
|
|
384
|
-
* Maps to `trace` level internally.
|
|
385
|
-
*
|
|
386
|
-
* @example `await logger.verbose('Socket message received', { event: 'ping', size: 42 })`
|
|
387
|
-
*/
|
|
388
|
-
verbose(message: string, data: Record<string, unknown>): Promise<void>;
|
|
389
|
-
/**
|
|
390
|
-
* NestJS compat overload — optional context string, returns `void`.
|
|
391
|
-
*
|
|
392
|
-
* @example `logger.verbose('Connection established', 'WebSocketGateway')`
|
|
393
|
-
*/
|
|
394
|
-
verbose(message: unknown, context?: string): void;
|
|
395
|
-
/**
|
|
396
|
-
* Native async `trace` — lowest verbosity level, structured data.
|
|
397
|
-
*/
|
|
398
|
-
trace(message: string, data?: Record<string, unknown>): Promise<void>;
|
|
399
|
-
/**
|
|
400
|
-
* Log at any named level with structured data.
|
|
401
|
-
*/
|
|
402
|
-
logLevel(level: string, message: string, data?: Record<string, unknown>): Promise<void>;
|
|
403
|
-
time(label: string): void;
|
|
404
|
-
timeEnd(label: string): Promise<number | undefined>;
|
|
405
|
-
timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
|
|
406
|
-
setContext(context: string): void;
|
|
407
|
-
getContext(): string | undefined;
|
|
408
|
-
setLevel(level: LogLevelString): void;
|
|
409
|
-
getLevel(): LogLevelString;
|
|
410
|
-
child(context: string, data?: Record<string, unknown>): LogixiaLoggerService;
|
|
411
|
-
getCurrentTraceId(): string | undefined;
|
|
412
|
-
/** Returns the AsyncLocalStorage key currently used to store the trace ID. */
|
|
413
|
-
get traceContextKey(): string;
|
|
414
|
-
close(): Promise<void>;
|
|
415
|
-
static create<T extends LoggerConfig<Record<string, number>>>(config?: T): LogixiaServiceWithLevels<T>;
|
|
416
|
-
getLogger(): LogixiaLogger;
|
|
417
|
-
private setContextIfProvided;
|
|
418
|
-
private formatMessage;
|
|
419
|
-
}
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/core/kafka-trace.interceptor.d.ts
|
|
422
|
-
/**
|
|
423
|
-
* Observable counters exposed for monitoring Kafka consumer trace hygiene.
|
|
424
|
-
*
|
|
425
|
-
* Usage:
|
|
426
|
-
* import { KafkaTraceInterceptor } from 'logixia/nest';
|
|
427
|
-
* setInterval(() => {
|
|
428
|
-
* myMetrics.gauge('kafka.trace.dropped', KafkaTraceInterceptor.metrics.dropped);
|
|
429
|
-
* }, 10_000);
|
|
430
|
-
*/
|
|
431
|
-
interface KafkaTraceMetrics {
|
|
432
|
-
/** Messages processed where a traceId was successfully resolved (body/header/ALS). */
|
|
433
|
-
accepted: number;
|
|
434
|
-
/** Messages handled without any traceId — `requireTraceId: false`. */
|
|
435
|
-
acceptedWithoutTrace: number;
|
|
436
|
-
/** Messages dropped because `requireTraceId: true` and no traceId was found. */
|
|
437
|
-
dropped: number;
|
|
438
|
-
}
|
|
439
|
-
declare class KafkaTraceInterceptor implements NestInterceptor {
|
|
440
|
-
private readonly config?;
|
|
441
|
-
private readonly requireTraceId;
|
|
442
|
-
/**
|
|
443
|
-
* Process-wide counters. Readable from anywhere — scrape into your metrics
|
|
444
|
-
* system (Prometheus, Datadog, CloudWatch) on an interval.
|
|
445
|
-
*/
|
|
446
|
-
static readonly metrics: KafkaTraceMetrics;
|
|
447
|
-
/** Reset counters (tests). */
|
|
448
|
-
static resetMetrics(): void;
|
|
449
|
-
private readonly ctx;
|
|
450
|
-
/**
|
|
451
|
-
* @param config - TraceIdConfig options (extractor keys, contextKey, etc.)
|
|
452
|
-
* @param requireTraceId - When true, messages with no traceId are silently skipped
|
|
453
|
-
* (EMPTY Observable — message is ack'd, consumer stays alive).
|
|
454
|
-
* A WARN is logged AND `KafkaTraceInterceptor.metrics.dropped`
|
|
455
|
-
* increments so the missing traceId is observable end-to-end.
|
|
456
|
-
* Default: false (handler runs without trace context).
|
|
457
|
-
*/
|
|
458
|
-
constructor(config?: TraceIdConfig | undefined, requireTraceId?: boolean);
|
|
459
|
-
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
460
|
-
}
|
|
461
|
-
//#endregion
|
|
462
|
-
//#region src/core/websocket-trace.interceptor.d.ts
|
|
463
|
-
declare class WebSocketTraceInterceptor implements NestInterceptor {
|
|
464
|
-
private readonly config?;
|
|
465
|
-
private readonly ctx;
|
|
466
|
-
constructor(config?: TraceIdConfig | undefined);
|
|
467
|
-
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
468
|
-
}
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/core/logitron-logger.module.d.ts
|
|
471
|
-
declare const LOGIXIA_LOGGER_CONFIG = "LOGIXIA_LOGGER_CONFIG";
|
|
472
|
-
declare const LOGIXIA_TRACE_CONFIG = "TRACE_CONFIG";
|
|
473
|
-
declare const LOGIXIA_LOGGER_PREFIX = "LOGIXIA_LOGGER_";
|
|
474
|
-
interface LogixiaAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
475
|
-
useExisting?: Type<LogixiaOptionsFactory>;
|
|
476
|
-
useClass?: Type<LogixiaOptionsFactory>;
|
|
477
|
-
useFactory?: (...args: unknown[]) => Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
|
|
478
|
-
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
479
|
-
}
|
|
480
|
-
interface LogixiaOptionsFactory {
|
|
481
|
-
createLogixiaOptions(): Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Logixia Logger Module for NestJS dependency injection
|
|
485
|
-
*/
|
|
486
|
-
declare class LogixiaLoggerModule implements NestModule {
|
|
487
|
-
private config;
|
|
488
|
-
private static loggerConfig;
|
|
489
|
-
/**
|
|
490
|
-
* @internal Backing field for the global logger. Do not read or write
|
|
491
|
-
* directly — use {@link getGlobalLogger} / {@link _setGlobalLogger} which
|
|
492
|
-
* enforce single-init semantics.
|
|
493
|
-
*/
|
|
494
|
-
static _globalLogger: LogixiaLoggerService | null;
|
|
495
|
-
/**
|
|
496
|
-
* @internal Set the global logger exactly once.
|
|
497
|
-
*
|
|
498
|
-
* Called from the module's forRoot / forRootAsync factory. If the module is
|
|
499
|
-
* initialised more than once in the same process (nested DI context, test
|
|
500
|
-
* harness creating multiple apps, hot reload, etc.) a warning is written to
|
|
501
|
-
* stderr and the first logger wins — silently overwriting would allow the
|
|
502
|
-
* newer instance's transport config to replace the live one while the old
|
|
503
|
-
* one is still being used by registered shutdown hooks, decorators, etc.
|
|
504
|
-
*
|
|
505
|
-
* Use {@link _resetGlobalLogger} in tests to reset between runs.
|
|
506
|
-
*/
|
|
507
|
-
static _setGlobalLogger(service: LogixiaLoggerService): void;
|
|
508
|
-
/** @internal Clear the global logger. Tests only. */
|
|
509
|
-
static _resetGlobalLogger(): void;
|
|
510
|
-
/**
|
|
511
|
-
* Returns the global LogixiaLoggerService instance that was created when the
|
|
512
|
-
* module booted. Useful for logging outside of NestJS DI — utility functions,
|
|
513
|
-
* plain scripts, decorators — without injecting the service everywhere.
|
|
514
|
-
*
|
|
515
|
-
* Returns `null` if called before `LogixiaLoggerModule.forRoot[Async]()` has
|
|
516
|
-
* been initialised (i.e. before the NestJS app has started).
|
|
517
|
-
*
|
|
518
|
-
* @example
|
|
519
|
-
* ```ts
|
|
520
|
-
* // some-util.ts
|
|
521
|
-
* import { LogixiaLoggerModule } from 'logixia/nest';
|
|
522
|
-
*
|
|
523
|
-
* export function doSomething() {
|
|
524
|
-
* LogixiaLoggerModule.getGlobalLogger()?.info('doing something');
|
|
525
|
-
* }
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
static getGlobalLogger(): LogixiaLoggerService | null;
|
|
529
|
-
configure(consumer: MiddlewareConsumer): void;
|
|
530
|
-
/**
|
|
531
|
-
* Configure the module with synchronous options
|
|
532
|
-
*/
|
|
533
|
-
static forRoot(config?: Partial<LoggerConfig>): {
|
|
534
|
-
module: typeof LogixiaLoggerModule;
|
|
535
|
-
providers: ({
|
|
536
|
-
provide: string;
|
|
537
|
-
useValue: Partial<LoggerConfig<Record<string, number>>>;
|
|
538
|
-
useFactory?: never;
|
|
539
|
-
inject?: never;
|
|
540
|
-
} | {
|
|
541
|
-
provide: string;
|
|
542
|
-
useValue: TraceIdConfig;
|
|
543
|
-
useFactory?: never;
|
|
544
|
-
inject?: never;
|
|
545
|
-
} | {
|
|
546
|
-
provide: typeof LogixiaLoggerService;
|
|
547
|
-
useFactory: (loggerConfig: Partial<LoggerConfig>) => LogixiaLoggerService;
|
|
548
|
-
inject: string[];
|
|
549
|
-
useValue?: never;
|
|
550
|
-
} | {
|
|
551
|
-
provide: typeof KafkaTraceInterceptor;
|
|
552
|
-
useFactory: (traceConfig: TraceIdConfig | undefined) => KafkaTraceInterceptor;
|
|
553
|
-
inject: string[];
|
|
554
|
-
useValue?: never;
|
|
555
|
-
} | {
|
|
556
|
-
provide: typeof WebSocketTraceInterceptor;
|
|
557
|
-
useFactory: (traceConfig: TraceIdConfig | undefined) => WebSocketTraceInterceptor;
|
|
558
|
-
inject: string[];
|
|
559
|
-
useValue?: never;
|
|
560
|
-
})[];
|
|
561
|
-
exports: (string | typeof WebSocketTraceInterceptor | typeof LogixiaLoggerService | typeof KafkaTraceInterceptor)[];
|
|
562
|
-
global: boolean;
|
|
563
|
-
};
|
|
564
|
-
/**
|
|
565
|
-
* Configure the module with asynchronous options
|
|
566
|
-
*/
|
|
567
|
-
static forRootAsync(options: LogixiaAsyncOptions): {
|
|
568
|
-
module: typeof LogixiaLoggerModule;
|
|
569
|
-
imports: (Type<any> | _nestjs_common0.DynamicModule | Promise<_nestjs_common0.DynamicModule> | _nestjs_common0.ForwardReference<any>)[];
|
|
570
|
-
providers: ({
|
|
571
|
-
provide: string;
|
|
572
|
-
useFactory: (...args: unknown[]) => Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
|
|
573
|
-
inject: (InjectionToken | OptionalFactoryDependency)[];
|
|
574
|
-
} | {
|
|
575
|
-
provide: string;
|
|
576
|
-
useFactory: (optionsFactory: LogixiaOptionsFactory) => Promise<Partial<LoggerConfig<Record<string, number>>>>;
|
|
577
|
-
inject: Type<LogixiaOptionsFactory>[];
|
|
578
|
-
} | {
|
|
579
|
-
provide: Type<LogixiaOptionsFactory>;
|
|
580
|
-
useClass: Type<LogixiaOptionsFactory>;
|
|
581
|
-
} | {
|
|
582
|
-
provide: string;
|
|
583
|
-
useFactory: (loggerConfig: Partial<LoggerConfig>) => TraceIdConfig;
|
|
584
|
-
inject: string[];
|
|
585
|
-
} | {
|
|
586
|
-
provide: typeof LogixiaLoggerService;
|
|
587
|
-
useFactory: (loggerConfig: Partial<LoggerConfig>) => LogixiaLoggerService;
|
|
588
|
-
inject: string[];
|
|
589
|
-
} | {
|
|
590
|
-
provide: typeof KafkaTraceInterceptor;
|
|
591
|
-
useFactory: (traceConfig: TraceIdConfig | undefined) => KafkaTraceInterceptor;
|
|
592
|
-
inject: string[];
|
|
593
|
-
} | {
|
|
594
|
-
provide: typeof WebSocketTraceInterceptor;
|
|
595
|
-
useFactory: (traceConfig: TraceIdConfig | undefined) => WebSocketTraceInterceptor;
|
|
596
|
-
inject: string[];
|
|
597
|
-
})[];
|
|
598
|
-
exports: (string | typeof WebSocketTraceInterceptor | typeof LogixiaLoggerService | typeof KafkaTraceInterceptor)[];
|
|
599
|
-
global: boolean;
|
|
600
|
-
};
|
|
601
|
-
/**
|
|
602
|
-
* Create feature-specific logger instances
|
|
603
|
-
*/
|
|
604
|
-
static forFeature(context: string): {
|
|
605
|
-
module: typeof LogixiaLoggerModule;
|
|
606
|
-
providers: {
|
|
607
|
-
provide: string;
|
|
608
|
-
useFactory: (baseLogger: LogixiaLoggerService) => LogixiaLoggerService;
|
|
609
|
-
inject: (typeof LogixiaLoggerService)[];
|
|
610
|
-
}[];
|
|
611
|
-
exports: string[];
|
|
612
|
-
};
|
|
613
|
-
private static createAsyncProviders;
|
|
614
|
-
private static createAsyncOptionsProvider;
|
|
615
|
-
}
|
|
616
|
-
//#endregion
|
|
617
|
-
//#region src/core/nestjs-extras.d.ts
|
|
618
|
-
/**
|
|
619
|
-
* Inject the Logixia logger registered in the current NestJS DI container.
|
|
620
|
-
*
|
|
621
|
-
* Equivalent to `@Inject(LOGIXIA_LOGGER_TOKEN)` but without needing to import
|
|
622
|
-
* the internal token constant yourself.
|
|
623
|
-
*
|
|
624
|
-
* @example
|
|
625
|
-
* ```ts
|
|
626
|
-
* constructor(@InjectLogger() private readonly logger: LogixiaLoggerService) {}
|
|
627
|
-
* ```
|
|
628
|
-
*/
|
|
629
|
-
declare const InjectLogger: () => ParameterDecorator;
|
|
630
|
-
interface LogMethodOptions {
|
|
631
|
-
/**
|
|
632
|
-
* Log level to use for entry / exit messages.
|
|
633
|
-
* @default 'debug'
|
|
634
|
-
*/
|
|
635
|
-
level?: LogLevelString;
|
|
636
|
-
/**
|
|
637
|
-
* Whether to log the arguments passed to the method.
|
|
638
|
-
* Disable for high-throughput hot paths.
|
|
639
|
-
* @default true
|
|
640
|
-
*/
|
|
641
|
-
logArgs?: boolean;
|
|
642
|
-
/**
|
|
643
|
-
* Whether to log the return value of the method.
|
|
644
|
-
* @default false
|
|
645
|
-
*/
|
|
646
|
-
logResult?: boolean;
|
|
647
|
-
/**
|
|
648
|
-
* Whether to log error stack traces for thrown errors.
|
|
649
|
-
* @default true
|
|
650
|
-
*/
|
|
651
|
-
logErrors?: boolean;
|
|
652
|
-
/**
|
|
653
|
-
* Custom label used in log messages instead of the auto-detected class.method name.
|
|
654
|
-
*/
|
|
655
|
-
label?: string;
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Method decorator that auto-logs entry, exit, duration, and errors.
|
|
659
|
-
*
|
|
660
|
-
* Preserves the original method's sync/async contract: a synchronous method
|
|
661
|
-
* stays synchronous (returns its value directly, with logs emitted
|
|
662
|
-
* fire-and-forget), and an async method is awaited so exit/error logs reflect
|
|
663
|
-
* the resolved result. Attaches to the logger found on the class instance via a
|
|
664
|
-
* `logger` property (the conventional NestJS name).
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* ```ts
|
|
668
|
-
* @LogMethod({ level: 'info', logArgs: true })
|
|
669
|
-
* async processPayment(orderId: string): Promise<void> { … }
|
|
670
|
-
* ```
|
|
671
|
-
*/
|
|
672
|
-
declare function LogMethod(options?: LogMethodOptions): MethodDecorator;
|
|
673
|
-
/**
|
|
674
|
-
* Global NestJS exception filter that converts any exception into the standard
|
|
675
|
-
* `LogixiaErrorResponse` wire format and logs it with full request context.
|
|
676
|
-
*
|
|
677
|
-
* Handles three exception types in priority order:
|
|
678
|
-
* 1. `LogixiaException` — typed fields used directly
|
|
679
|
-
* 2. NestJS `HttpException` — status + message extracted
|
|
680
|
-
* 3. Unknown / plain Error — falls back to 500 `server_error`
|
|
681
|
-
*
|
|
682
|
-
* **Debug block (off by default):**
|
|
683
|
-
* Responses never include the `debug` block (stack trace, service, duration)
|
|
684
|
-
* unless `exposeDebug: true` is passed in the filter options. The underlying
|
|
685
|
-
* `cause` is only added when `exposeCause: true` is also set. Enable explicitly
|
|
686
|
-
* for local development only, e.g.
|
|
687
|
-
* `new LogixiaExceptionFilter(logger, undefined, { exposeDebug: process.env.NODE_ENV === 'development' })`.
|
|
688
|
-
*
|
|
689
|
-
* **Trace ID headers:**
|
|
690
|
-
* `X-Trace-ID` and `X-Request-ID` are echoed back on every error response so
|
|
691
|
-
* clients can correlate with server logs.
|
|
692
|
-
*
|
|
693
|
-
* **Retry-After header:**
|
|
694
|
-
* Automatically added for `429` responses (`Retry-After: 60`).
|
|
695
|
-
*
|
|
696
|
-
* Register in `main.ts`:
|
|
697
|
-
* ```ts
|
|
698
|
-
* const logger = app.get(LogixiaLoggerService);
|
|
699
|
-
* app.useGlobalFilters(new LogixiaExceptionFilter(logger));
|
|
700
|
-
* ```
|
|
701
|
-
*/
|
|
702
|
-
interface LogixiaExceptionFilterOptions {
|
|
703
|
-
/**
|
|
704
|
-
* Include the `debug` block (stack trace, service, duration) in error responses.
|
|
705
|
-
* @default false
|
|
706
|
-
*/
|
|
707
|
-
exposeDebug?: boolean;
|
|
708
|
-
/**
|
|
709
|
-
* Include `debug.cause` as well. Requires `exposeDebug`.
|
|
710
|
-
* @default false
|
|
711
|
-
*/
|
|
712
|
-
exposeCause?: boolean;
|
|
713
|
-
}
|
|
714
|
-
/** Injection token for {@link LogixiaExceptionFilterOptions}. */
|
|
715
|
-
declare const LOGIXIA_EXCEPTION_FILTER_OPTIONS = "LOGIXIA_EXCEPTION_FILTER_OPTIONS";
|
|
716
|
-
declare class LogixiaExceptionFilter implements ExceptionFilter {
|
|
717
|
-
private readonly _logger;
|
|
718
|
-
private readonly _traceConfig;
|
|
719
|
-
private readonly _options;
|
|
720
|
-
constructor(logger?: LogixiaLoggerService, loggerConfig?: Partial<LoggerConfig>, options?: LogixiaExceptionFilterOptions);
|
|
721
|
-
catch(exception: unknown, host: ArgumentsHost): void;
|
|
722
|
-
}
|
|
723
|
-
//#endregion
|
|
724
|
-
export { usePlugin as C, globalPluginRegistry as S, LogixiaServiceWithLevels as _, LogixiaExceptionFilter as a, LogixiaPlugin as b, LOGIXIA_LOGGER_PREFIX as c, LogixiaLoggerModule as d, LogixiaOptionsFactory as f, LogixiaServiceWith as g, LogixiaLoggerService as h, LogMethodOptions as i, LOGIXIA_TRACE_CONFIG as l, KafkaTraceInterceptor as m, LOGIXIA_EXCEPTION_FILTER_OPTIONS as n, LogixiaExceptionFilterOptions as o, WebSocketTraceInterceptor as p, LogMethod as r, LOGIXIA_LOGGER_CONFIG as s, InjectLogger as t, LogixiaAsyncOptions as u, LogixiaLogger as v, PluginRegistry as x, createLogger as y };
|
|
725
|
-
//# sourceMappingURL=nestjs-extras-OkC796py.d.mts.map
|