logixia 2.0.0 → 2.0.6
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 +172 -2597
- package/dist/async-context-2mbUKhcl.mjs +132 -0
- package/dist/async-context-2mbUKhcl.mjs.map +1 -0
- package/dist/async-context-DUFMDYAr.js +148 -0
- package/dist/async-context-DUFMDYAr.js.map +1 -0
- package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-Bu4S2I2q.js} +32 -20
- package/dist/azure-monitor.transport-Bu4S2I2q.js.map +1 -0
- package/dist/{azure-monitor.transport-Cn_3Usvu.d.ts → azure-monitor.transport-Bvf7Xegt.d.ts} +3 -6
- package/dist/azure-monitor.transport-Bvf7Xegt.d.ts.map +1 -0
- package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-C1RWAumT.mjs} +27 -15
- package/dist/azure-monitor.transport-C1RWAumT.mjs.map +1 -0
- package/dist/{azure-monitor.transport-D7Da4RAb.d.mts → azure-monitor.transport-CbSHOnNX.d.mts} +3 -6
- package/dist/azure-monitor.transport-CbSHOnNX.d.mts.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-BvXLDPlV.mjs} +21 -7
- package/dist/batch-buffer-BvXLDPlV.mjs.map +1 -0
- package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-C7Am4Mw-.js} +53 -40
- package/dist/batch-buffer-C7Am4Mw-.js.map +1 -0
- package/dist/browser.d.mts +47 -27
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +47 -27
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +464 -62
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +465 -65
- package/dist/browser.mjs.map +1 -1
- package/dist/{builder-0gEzRopq.mjs → builder-DhNhvOkt.mjs} +307 -246
- package/dist/builder-DhNhvOkt.mjs.map +1 -0
- package/dist/{builder-D44QktIo.js → builder-yFvJrz7o.js} +435 -399
- package/dist/builder-yFvJrz7o.js.map +1 -0
- package/dist/cli/index.js +216 -125
- 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-DsEq633o.d.ts → cloudwatch.transport-CQyT6U91.d.ts} +2 -6
- package/dist/cloudwatch.transport-CQyT6U91.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-Ch1Uae-0.js} +61 -36
- package/dist/cloudwatch.transport-Ch1Uae-0.js.map +1 -0
- package/dist/{cloudwatch.transport-UlyZFWMn.d.mts → cloudwatch.transport-CjVrI6S4.d.mts} +2 -6
- package/dist/cloudwatch.transport-CjVrI6S4.d.mts.map +1 -0
- package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-DZqF2xZO.mjs} +54 -28
- package/dist/cloudwatch.transport-DZqF2xZO.mjs.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 +15 -69
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +15 -69
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +69 -20
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +67 -17
- package/dist/correlation.mjs.map +1 -1
- package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-BSLkzw18.js} +16 -13
- package/dist/entry-fields-BSLkzw18.js.map +1 -0
- package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-J1OBi24o.mjs} +11 -7
- package/dist/entry-fields-J1OBi24o.mjs.map +1 -0
- package/dist/gcp.d.mts +1 -2
- package/dist/gcp.d.ts +1 -2
- package/dist/gcp.js +3 -7
- package/dist/gcp.mjs +1 -7
- package/dist/{gcp.transport-B7oc97sG.d.ts → gcp.transport-BCIvdFV-.d.ts} +5 -8
- package/dist/gcp.transport-BCIvdFV-.d.ts.map +1 -0
- package/dist/{gcp.transport-GrJurKo8.d.mts → gcp.transport-D9SdLPwP.d.mts} +5 -8
- package/dist/gcp.transport-D9SdLPwP.d.mts.map +1 -0
- package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-DVCmnA3b.mjs} +59 -16
- package/dist/gcp.transport-DVCmnA3b.mjs.map +1 -0
- package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-Dy2Lf8FI.js} +64 -22
- package/dist/gcp.transport-Dy2Lf8FI.js.map +1 -0
- package/dist/http-shapes-BnBkJcid.d.mts +32 -0
- package/dist/http-shapes-BnBkJcid.d.mts.map +1 -0
- package/dist/http-shapes-BnBkJcid.d.ts +32 -0
- package/dist/http-shapes-BnBkJcid.d.ts.map +1 -0
- package/dist/{index-3mw5gaCw.d.mts → index-BSTtFcQ6.d.mts} +142 -13
- package/dist/index-BSTtFcQ6.d.mts.map +1 -0
- package/dist/{index-DhIoploR.d.ts → index-CFDGkI8n.d.ts} +142 -13
- package/dist/index-CFDGkI8n.d.ts.map +1 -0
- package/dist/index.d.mts +114 -217
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +113 -216
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +182 -279
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -256
- package/dist/index.mjs.map +1 -1
- package/dist/internal-log-Bg4V1cPg.mjs +170 -0
- package/dist/internal-log-Bg4V1cPg.mjs.map +1 -0
- package/dist/internal-log-By4Govmu.js +223 -0
- package/dist/internal-log-By4Govmu.js.map +1 -0
- package/dist/{logitron-logger-UVeN-mQm.d.ts → logitron-logger-D22Yb61K.d.mts} +121 -100
- package/dist/logitron-logger-D22Yb61K.d.mts.map +1 -0
- package/dist/{logitron-logger-BFDSO8Io.d.mts → logitron-logger-D_MYYrQt.d.ts} +121 -100
- package/dist/logitron-logger-D_MYYrQt.d.ts.map +1 -0
- package/dist/middleware.d.mts +13 -28
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +13 -28
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +20 -81
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +17 -79
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +37 -48
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +37 -48
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +124 -135
- package/dist/nest.js.map +1 -1
- package/dist/nest.mjs +69 -78
- package/dist/nest.mjs.map +1 -1
- package/dist/{transport.manager-BiuCAJd2.mjs → otel-Dt5riXuE.mjs} +275 -117
- package/dist/otel-Dt5riXuE.mjs.map +1 -0
- package/dist/{transport.manager-CXbKKdVE.js → otel-DyeH6DVR.js} +373 -178
- package/dist/otel-DyeH6DVR.js.map +1 -0
- package/dist/own-property-BWkibepN.js +40 -0
- package/dist/own-property-BWkibepN.js.map +1 -0
- package/dist/own-property-CjFw9qwZ.mjs +29 -0
- package/dist/own-property-CjFw9qwZ.mjs.map +1 -0
- package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-BgNykH9M.mjs} +40 -9
- package/dist/request-trace-BgNykH9M.mjs.map +1 -0
- package/dist/{trace.utils-DpBOLDtq.js → request-trace-ByujsUZk.js} +117 -77
- package/dist/request-trace-ByujsUZk.js.map +1 -0
- package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
- package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-B5p5ktFe.mjs} +39 -15
- package/dist/safe-stringify-B5p5ktFe.mjs.map +1 -0
- package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-J3sh-7YM.js} +59 -36
- package/dist/safe-stringify-J3sh-7YM.js.map +1 -0
- package/dist/{search-C4V0OMEn.js → search-CRjhHxe9.js} +319 -92
- package/dist/search-CRjhHxe9.js.map +1 -0
- package/dist/{search-CNh9uVwR.d.ts → search-DA3ft3X5.d.mts} +5 -22
- package/dist/search-DA3ft3X5.d.mts.map +1 -0
- package/dist/{search-BFbu_oVn.mjs → search-DAXKE-P9.mjs} +289 -62
- package/dist/search-DAXKE-P9.mjs.map +1 -0
- package/dist/{search-DXANsQ2n.d.mts → search-DEl3Pe47.d.ts} +5 -22
- package/dist/search-DEl3Pe47.d.ts.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-CmK2wVkr.js +272 -0
- package/dist/secret-config-CmK2wVkr.js.map +1 -0
- package/dist/secret-config-Dhb6pqTU.mjs +210 -0
- package/dist/secret-config-Dhb6pqTU.mjs.map +1 -0
- package/dist/{slack.transport-CXjQYOes.d.ts → slack.transport-BDyENuR0.d.mts} +56 -9
- package/dist/slack.transport-BDyENuR0.d.mts.map +1 -0
- package/dist/{slack.transport-Bzw7sucI.mjs → slack.transport-BTEwsREY.mjs} +263 -31
- package/dist/slack.transport-BTEwsREY.mjs.map +1 -0
- package/dist/{slack.transport-BZzoXDPn.d.mts → slack.transport-C6E0l4kw.d.ts} +56 -9
- package/dist/slack.transport-C6E0l4kw.d.ts.map +1 -0
- package/dist/{slack.transport-BfJRouB2.js → slack.transport-UbYvOdKx.js} +286 -42
- package/dist/slack.transport-UbYvOdKx.js.map +1 -0
- package/dist/testing.d.mts +13 -11
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.d.ts +13 -11
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +41 -7
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +40 -6
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.types-CGoHpWQR.d.ts → transport.types-CzJq4IrF.d.mts} +14 -5
- package/dist/transport.types-CzJq4IrF.d.mts.map +1 -0
- package/dist/{transport.types-BMnurPcc.d.mts → transport.types-CzJq4IrF.d.ts} +14 -5
- package/dist/transport.types-CzJq4IrF.d.ts.map +1 -0
- package/dist/transports.d.mts +39 -41
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +39 -41
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +19 -22
- package/dist/transports.mjs +7 -13
- package/dist/worker-entry.js +438 -107
- 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-JvGPog3C.d.mts → worker.transport-B9mCQSM1.d.ts} +7 -6
- package/dist/worker.transport-B9mCQSM1.d.ts.map +1 -0
- package/dist/{worker.transport-CdzSZJmw.d.ts → worker.transport-Bl8lFRck.d.mts} +7 -6
- package/dist/worker.transport-Bl8lFRck.d.mts.map +1 -0
- package/dist/{worker.transport-lPxO2MVL.mjs → worker.transport-BmmOKb1-.mjs} +43 -10
- package/dist/worker.transport-BmmOKb1-.mjs.map +1 -0
- package/dist/{worker.transport-BdPxu3PN.js → worker.transport-DxxbqQCG.js} +48 -15
- package/dist/worker.transport-DxxbqQCG.js.map +1 -0
- package/package.json +51 -75
- package/dist/async-context-BzJrbfQs.mjs +0 -72
- package/dist/async-context-BzJrbfQs.mjs.map +0 -1
- package/dist/async-context-DyQQYq3I.js +0 -92
- package/dist/async-context-DyQQYq3I.js.map +0 -1
- package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-Cn_3Usvu.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D7Da4RAb.d.mts.map +0 -1
- package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
- package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
- package/dist/builder-0gEzRopq.mjs.map +0 -1
- package/dist/builder-D44QktIo.js.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/cloudwatch.transport-DsEq633o.d.ts.map +0 -1
- package/dist/cloudwatch.transport-UlyZFWMn.d.mts.map +0 -1
- package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
- package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
- package/dist/gcp.transport-B7oc97sG.d.ts.map +0 -1
- package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
- package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
- package/dist/gcp.transport-GrJurKo8.d.mts.map +0 -1
- package/dist/index-3mw5gaCw.d.mts.map +0 -1
- package/dist/index-DhIoploR.d.ts.map +0 -1
- package/dist/internal-log-BUJYMZbE.js +0 -70
- package/dist/internal-log-BUJYMZbE.js.map +0 -1
- package/dist/internal-log-Cm8SOWSV.mjs +0 -52
- package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
- package/dist/logitron-logger-BFDSO8Io.d.mts.map +0 -1
- package/dist/logitron-logger-UVeN-mQm.d.ts.map +0 -1
- package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
- package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
- package/dist/search-BFbu_oVn.mjs.map +0 -1
- package/dist/search-C4V0OMEn.js.map +0 -1
- package/dist/search-CNh9uVwR.d.ts.map +0 -1
- package/dist/search-DXANsQ2n.d.mts.map +0 -1
- package/dist/slack.transport-BZzoXDPn.d.mts.map +0 -1
- package/dist/slack.transport-BfJRouB2.js.map +0 -1
- package/dist/slack.transport-Bzw7sucI.mjs.map +0 -1
- package/dist/slack.transport-CXjQYOes.d.ts.map +0 -1
- package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
- package/dist/trace.utils-DpBOLDtq.js.map +0 -1
- package/dist/transport.manager-BiuCAJd2.mjs.map +0 -1
- package/dist/transport.manager-CXbKKdVE.js.map +0 -1
- package/dist/transport.types-BMnurPcc.d.mts.map +0 -1
- package/dist/transport.types-CGoHpWQR.d.ts.map +0 -1
- package/dist/worker.transport-BdPxu3PN.js.map +0 -1
- package/dist/worker.transport-CdzSZJmw.d.ts.map +0 -1
- package/dist/worker.transport-JvGPog3C.d.mts.map +0 -1
- package/dist/worker.transport-lPxO2MVL.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { _ as TransportLogEntry, d as ITransport, h as TransportConfig } from "./transport.types-CzJq4IrF.mjs";
|
|
2
|
+
import { n as HttpResponseShape, t as HttpRequestShape } from "./http-shapes-BnBkJcid.mjs";
|
|
3
|
+
import { A as TraceIdConfig, B as usePlugin, C as LogixiaLoggerInstance, D as ReservedLevelName, E as RequestContext, F as RequestMetrics, I as RequestTiming, L as LogixiaPlugin, M as HttpError, N as HttpRequest, O as SamplingConfig, P as HttpResponse, R as PluginRegistry, S as LogixiaLoggerDefault, T as RedactConfig, _ as LogFieldKey, a as DEFAULT_LOG_LEVELS, b as LoggerConfig, c as ExtractLevels, d as ILogFormatter, f as ILogger, g as LogEntry, h as LogColor, i as DEFAULT_LOG_COLORS, j as TraceIdExtractorConfig, k as TimingEntry, l as GracefulShutdownConfig, m as ILoggerRuntimeControls, n as ContextData, o as Environment, p as ILoggerDefault, r as CustomLevelMethods, s as ErrorSerializationOptions, t as AdaptiveSamplingConfig, u as IBaseLogger, v as LogLevel, w as NamespaceLevels, x as LoggerWithLevels, y as LogLevelString, z as globalPluginRegistry } from "./index-BSTtFcQ6.mjs";
|
|
4
|
+
import { n as createLogger$1, t as LogixiaLogger } from "./logitron-logger-D22Yb61K.mjs";
|
|
5
|
+
import { a as DiscordTransport, c as OtlpLogTransportConfig, i as DiscordEmbed, l as toOtelSeverity, n as SlackTransport, o as DiscordTransportConfig, r as SlackTransportConfig, s as OtlpLogTransport, t as SlackMessage } from "./slack.transport-BDyENuR0.mjs";
|
|
6
|
+
import { A as SearchStats, C as SearchFilters, D as SearchPreset, E as SearchOptions, F as SuggestionType, I as TimeRange, L as TimelineEvent, M as SemanticIndex, N as SimilarLog, O as SearchQuery, P as SortField, S as RelativeTime, T as SearchMatch, _ as ParsedNLQuery, a as ILogSearchEngine, b as RelatedLog, c as SearchManager, d as CorrelatedLogs, f as EntityType, g as LogPattern, h as LogCorrelationSummary, i as BasicSearchEngine, j as SearchSuggestion, k as SearchResult, l as SearchManagerConfig, m as LogCluster, n as NLPSearchEngine, o as BasicLogIndexer, p as ExportOptions, r as CorrelationEngine, s as ILogIndexer, t as PatternRecognitionEngine, u as AnomalyDetection, v as QueryEntity, w as SearchHighlight, x as RelationshipType, y as QueryIntent } from "./search-DA3ft3X5.mjs";
|
|
7
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
-
|
|
9
|
-
//#region src/core/default-config.d.ts
|
|
8
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
10
9
|
/**
|
|
11
10
|
* Default configuration for Logixia logger
|
|
12
11
|
*/
|
|
13
|
-
declare const DEFAULT_CONFIG: {
|
|
12
|
+
export declare const DEFAULT_CONFIG: {
|
|
14
13
|
appName: string;
|
|
15
14
|
environment: Environment;
|
|
16
15
|
traceId: boolean;
|
|
@@ -43,9 +42,7 @@ declare const DEFAULT_CONFIG: {
|
|
|
43
42
|
};
|
|
44
43
|
outputs: string[];
|
|
45
44
|
};
|
|
46
|
-
|
|
47
|
-
//#region src/formatters/json.formatter.d.ts
|
|
48
|
-
declare class JsonFormatter implements ILogFormatter {
|
|
45
|
+
export declare class JsonFormatter implements ILogFormatter {
|
|
49
46
|
private includeTimestamp;
|
|
50
47
|
private includeLevel;
|
|
51
48
|
private includeAppName;
|
|
@@ -63,9 +60,7 @@ declare class JsonFormatter implements ILogFormatter {
|
|
|
63
60
|
format(entry: LogEntry): string;
|
|
64
61
|
private serializePayload;
|
|
65
62
|
}
|
|
66
|
-
|
|
67
|
-
//#region src/formatters/text.formatter.d.ts
|
|
68
|
-
declare class TextFormatter implements ILogFormatter {
|
|
63
|
+
export declare class TextFormatter implements ILogFormatter {
|
|
69
64
|
private colorize;
|
|
70
65
|
private includeTimestamp;
|
|
71
66
|
private includeAppName;
|
|
@@ -92,8 +87,6 @@ declare class TextFormatter implements ILogFormatter {
|
|
|
92
87
|
static createDetailed(): TextFormatter;
|
|
93
88
|
static createMinimal(): TextFormatter;
|
|
94
89
|
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/utils/error.utils.d.ts
|
|
97
90
|
/**
|
|
98
91
|
* Serialize an Error into a plain JSON-safe object, including:
|
|
99
92
|
* - `name`, `message`, `stack`
|
|
@@ -102,17 +95,15 @@ declare class TextFormatter implements ILogFormatter {
|
|
|
102
95
|
* - standard Node.js error fields (`code`, `statusCode`, `errno`, …)
|
|
103
96
|
* - any other enumerable own properties
|
|
104
97
|
*/
|
|
105
|
-
declare function serializeError(error: Error, options?: ErrorSerializationOptions): Record<string, unknown>;
|
|
98
|
+
export declare function serializeError(error: Error, options?: ErrorSerializationOptions): Record<string, unknown>;
|
|
106
99
|
/**
|
|
107
100
|
* Type guard: returns true if the value looks like an Error object.
|
|
108
101
|
*/
|
|
109
|
-
declare function isError(value: unknown): value is Error;
|
|
102
|
+
export declare function isError(value: unknown): value is Error;
|
|
110
103
|
/**
|
|
111
104
|
* Coerce any thrown value into a proper Error instance.
|
|
112
105
|
*/
|
|
113
|
-
declare function normalizeError(error: unknown): Error;
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/utils/otel.d.ts
|
|
106
|
+
export declare function normalizeError(error: unknown): Error;
|
|
116
107
|
/**
|
|
117
108
|
* logixia — OpenTelemetry auto trace-log correlation
|
|
118
109
|
*
|
|
@@ -189,7 +180,7 @@ interface OtelBridgeOptions {
|
|
|
189
180
|
* - No active span exists (root context)
|
|
190
181
|
* - The span context is invalid (all-zeros)
|
|
191
182
|
*/
|
|
192
|
-
declare function getActiveOtelContext(opts?: OtelBridgeOptions): OtelSpanContext | undefined;
|
|
183
|
+
export declare function getActiveOtelContext(opts?: OtelBridgeOptions): OtelSpanContext | undefined;
|
|
193
184
|
/**
|
|
194
185
|
* Returns a metadata object with OTel context fields ready to merge into a log call,
|
|
195
186
|
* using the configured field names.
|
|
@@ -204,7 +195,7 @@ declare function getActiveOtelContext(opts?: OtelBridgeOptions): OtelSpanContext
|
|
|
204
195
|
* });
|
|
205
196
|
* ```
|
|
206
197
|
*/
|
|
207
|
-
declare function getOtelMetaFields(opts?: OtelBridgeOptions): Record<string, unknown>;
|
|
198
|
+
export declare function getOtelMetaFields(opts?: OtelBridgeOptions): Record<string, unknown>;
|
|
208
199
|
/**
|
|
209
200
|
* Initialise the global OTel bridge.
|
|
210
201
|
*
|
|
@@ -218,26 +209,22 @@ declare function getOtelMetaFields(opts?: OtelBridgeOptions): Record<string, unk
|
|
|
218
209
|
* initOtelBridge();
|
|
219
210
|
* ```
|
|
220
211
|
*/
|
|
221
|
-
declare function initOtelBridge(opts?: OtelBridgeOptions): void;
|
|
212
|
+
export declare function initOtelBridge(opts?: OtelBridgeOptions): void;
|
|
222
213
|
/**
|
|
223
214
|
* Disable the OTel bridge (useful for tests).
|
|
224
215
|
*/
|
|
225
|
-
declare function disableOtelBridge(): void;
|
|
226
|
-
//#endregion
|
|
227
|
-
//#region src/utils/redact.utils.d.ts
|
|
216
|
+
export declare function disableOtelBridge(): void;
|
|
228
217
|
/**
|
|
229
218
|
* Redact an object according to the given RedactConfig and return a new
|
|
230
219
|
* top-level object. Subtrees with nothing to redact are shared with the input,
|
|
231
220
|
* never mutated. Circular references become `[Circular]`.
|
|
232
221
|
*/
|
|
233
|
-
declare function redactObject(obj: Record<string, unknown>, config: RedactConfig, _currentPath?: string): Record<string, unknown>;
|
|
222
|
+
export declare function redactObject(obj: Record<string, unknown>, config: RedactConfig, _currentPath?: string): Record<string, unknown>;
|
|
234
223
|
/**
|
|
235
224
|
* Apply redaction to a log payload (top-level call convenience wrapper).
|
|
236
225
|
* Returns a new object — never mutates the input.
|
|
237
226
|
*/
|
|
238
|
-
declare function applyRedaction(payload: Record<string, unknown> | undefined, config: RedactConfig | undefined): Record<string, unknown> | undefined;
|
|
239
|
-
//#endregion
|
|
240
|
-
//#region src/utils/runtime-control.d.ts
|
|
227
|
+
export declare function applyRedaction(payload: Record<string, unknown> | undefined, config: RedactConfig | undefined): Record<string, unknown> | undefined;
|
|
241
228
|
/** Minimal logger surface the runtime controls need. */
|
|
242
229
|
interface ReconfigurableLogger {
|
|
243
230
|
getLevel(): LogLevelString;
|
|
@@ -259,7 +246,7 @@ interface LevelSignalOptions {
|
|
|
259
246
|
* memorizable command (`kill -USR2 <pid>`) is enough to ratchet verbosity up
|
|
260
247
|
* while chasing a bug and back down again — no value to remember.
|
|
261
248
|
*/
|
|
262
|
-
declare function registerLevelSignal(logger: ReconfigurableLogger, options?: LevelSignalOptions): () => void;
|
|
249
|
+
export declare function registerLevelSignal(logger: ReconfigurableLogger, options?: LevelSignalOptions): () => void;
|
|
263
250
|
interface MinimalReq {
|
|
264
251
|
method?: string | undefined;
|
|
265
252
|
headers?: Record<string, string | string[] | undefined> | undefined;
|
|
@@ -290,11 +277,9 @@ interface MinimalRes {
|
|
|
290
277
|
* which also keeps cross-site form posts out) and a body of at most 16 KB
|
|
291
278
|
* (otherwise 413).
|
|
292
279
|
*/
|
|
293
|
-
declare function createLevelControlHandler(logger: ReconfigurableLogger, options?: {
|
|
280
|
+
export declare function createLevelControlHandler(logger: ReconfigurableLogger, options?: {
|
|
294
281
|
allowedLevels?: string[];
|
|
295
282
|
}): (req: MinimalReq, res: MinimalRes) => void;
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/utils/safe-stringify.d.ts
|
|
298
283
|
/**
|
|
299
284
|
* logixia — robust JSON serialization for log payloads.
|
|
300
285
|
*
|
|
@@ -334,27 +319,25 @@ interface SafeStringifyOptions {
|
|
|
334
319
|
* Serialize any value to JSON without throwing on circular references or BigInt.
|
|
335
320
|
* Circular refs become `"[Circular]"` (or `{ $ref }` pointers when `decycle`).
|
|
336
321
|
*/
|
|
337
|
-
declare function safeStringify(value: unknown, options?: SafeStringifyOptions): string;
|
|
322
|
+
export declare function safeStringify(value: unknown, options?: SafeStringifyOptions): string;
|
|
338
323
|
/**
|
|
339
324
|
* Replace repeated object references with round-trippable `{ "$ref": "$..." }`
|
|
340
325
|
* JSONPath pointers (the classic Crockford decycle). Pair with {@link retrocycle}
|
|
341
326
|
* to reconstruct the original shared/circular graph.
|
|
342
327
|
*/
|
|
343
|
-
declare function decycleValue(value: unknown, bigint?: 'string' | 'number'): unknown;
|
|
328
|
+
export declare function decycleValue(value: unknown, bigint?: 'string' | 'number'): unknown;
|
|
344
329
|
/**
|
|
345
330
|
* Inverse of {@link decycleValue}: resolve `{ "$ref": "$..." }` pointers back
|
|
346
331
|
* into the live object graph (mutates and returns the parsed input).
|
|
347
332
|
*/
|
|
348
|
-
declare function retrocycle<T>(root: T): T;
|
|
333
|
+
export declare function retrocycle<T>(root: T): T;
|
|
349
334
|
/**
|
|
350
335
|
* `JSON.stringify` for log output. Takes the plain fast path first and only
|
|
351
336
|
* falls back to {@link safeStringify} when that throws (a cycle, a BigInt, a
|
|
352
337
|
* throwing `toJSON`), so a bad payload costs nothing until it shows up.
|
|
353
338
|
* Never throws: if even the safe walk fails, the value is replaced by a marker.
|
|
354
339
|
*/
|
|
355
|
-
declare function stringifyForLog(value: unknown): string;
|
|
356
|
-
//#endregion
|
|
357
|
-
//#region src/utils/shutdown.utils.d.ts
|
|
340
|
+
export declare function stringifyForLog(value: unknown): string;
|
|
358
341
|
/**
|
|
359
342
|
* Graceful shutdown utilities for Logixia
|
|
360
343
|
*
|
|
@@ -362,8 +345,8 @@ declare function stringifyForLog(value: unknown): string;
|
|
|
362
345
|
* exits on SIGTERM / SIGINT — solving the "last N seconds of logs are lost on
|
|
363
346
|
* deployment" problem reported in Pino issue #2002 and LogDNA issue #15.
|
|
364
347
|
*/
|
|
365
|
-
type ExitMode = 'auto' | 'always' | 'never';
|
|
366
|
-
interface FlushOnExitOptions {
|
|
348
|
+
export type ExitMode = 'auto' | 'always' | 'never';
|
|
349
|
+
export interface FlushOnExitOptions {
|
|
367
350
|
/** How long (ms) to wait for transports to flush before force-exiting. Default: 5000 */
|
|
368
351
|
timeout?: number;
|
|
369
352
|
/** OS signals that trigger a graceful flush. Default: ['SIGTERM', 'SIGINT'] */
|
|
@@ -392,12 +375,12 @@ type Closeable = {
|
|
|
392
375
|
* Called automatically when `gracefulShutdown: true` is set in logger config.
|
|
393
376
|
*/
|
|
394
377
|
/** Test helper: number of loggers currently registered for graceful shutdown. */
|
|
395
|
-
declare function _shutdownRegistrySize(): number;
|
|
396
|
-
declare function registerForShutdown(logger: Closeable): void;
|
|
378
|
+
export declare function _shutdownRegistrySize(): number;
|
|
379
|
+
export declare function registerForShutdown(logger: Closeable): void;
|
|
397
380
|
/**
|
|
398
381
|
* Deregister a logger (e.g. after `logger.close()` is called manually).
|
|
399
382
|
*/
|
|
400
|
-
declare function deregisterFromShutdown(logger: Closeable): void;
|
|
383
|
+
export declare function deregisterFromShutdown(logger: Closeable): void;
|
|
401
384
|
/**
|
|
402
385
|
* Register SIGTERM / SIGINT handlers that flush all registered loggers before
|
|
403
386
|
* the process exits. Idempotent — the first call wins and later calls with
|
|
@@ -412,16 +395,14 @@ declare function deregisterFromShutdown(logger: Closeable): void;
|
|
|
412
395
|
* flushOnExit({ timeout: 5000 });
|
|
413
396
|
* ```
|
|
414
397
|
*/
|
|
415
|
-
declare function flushOnExit(options?: FlushOnExitOptions): void;
|
|
398
|
+
export declare function flushOnExit(options?: FlushOnExitOptions): void;
|
|
416
399
|
/**
|
|
417
400
|
* Remove all graceful shutdown handlers and clear the registry.
|
|
418
401
|
* Primarily useful in tests.
|
|
419
402
|
*/
|
|
420
|
-
declare function resetShutdownHandlers(): void;
|
|
421
|
-
//#endregion
|
|
422
|
-
//#region src/utils/trace.utils.d.ts
|
|
403
|
+
export declare function resetShutdownHandlers(): void;
|
|
423
404
|
/** Default key used to store the trace ID in AsyncLocalStorage. */
|
|
424
|
-
declare const TRACE_CONTEXT_KEY: "traceId";
|
|
405
|
+
export declare const TRACE_CONTEXT_KEY: "traceId";
|
|
425
406
|
/**
|
|
426
407
|
* Singleton that owns the AsyncLocalStorage and the active contextKey.
|
|
427
408
|
*
|
|
@@ -437,7 +418,7 @@ declare const TRACE_CONTEXT_KEY: "traceId";
|
|
|
437
418
|
* TraceContext.instance.contextKey // → 'traceId' (or custom)
|
|
438
419
|
* TraceContext.instance.getCurrentTraceId() // same as standalone fn
|
|
439
420
|
*/
|
|
440
|
-
declare class TraceContext {
|
|
421
|
+
export declare class TraceContext {
|
|
441
422
|
private static _instance;
|
|
442
423
|
readonly storage: AsyncLocalStorage<Record<string, unknown>>;
|
|
443
424
|
private _contextKey;
|
|
@@ -479,16 +460,16 @@ declare class TraceContext {
|
|
|
479
460
|
* The shared AsyncLocalStorage instance.
|
|
480
461
|
* @deprecated Prefer `TraceContext.instance.storage` for new code.
|
|
481
462
|
*/
|
|
482
|
-
declare const traceStorage: AsyncLocalStorage<Record<string, unknown>>;
|
|
463
|
+
export declare const traceStorage: AsyncLocalStorage<Record<string, unknown>>;
|
|
483
464
|
/** Returns the key currently used to store the trace ID in AsyncLocalStorage. */
|
|
484
|
-
declare function getTraceContextKey(): string;
|
|
465
|
+
export declare function getTraceContextKey(): string;
|
|
485
466
|
/** @internal Called by TraceMiddleware / traceMiddleware() when they boot. */
|
|
486
|
-
declare function _setActiveContextKey(key: string): void;
|
|
467
|
+
export declare function _setActiveContextKey(key: string): void;
|
|
487
468
|
/**
|
|
488
469
|
* Get the current trace ID from async context.
|
|
489
470
|
* Returns `undefined` when called outside a traced request.
|
|
490
471
|
*/
|
|
491
|
-
declare function getCurrentTraceId(): string | undefined;
|
|
472
|
+
export declare function getCurrentTraceId(): string | undefined;
|
|
492
473
|
/**
|
|
493
474
|
* Set trace ID in the CURRENT async context without starting a new one.
|
|
494
475
|
*
|
|
@@ -542,11 +523,11 @@ declare function getCurrentTraceId(): string | undefined;
|
|
|
542
523
|
* @deprecated Use `runWithTraceId(traceId, fn)` — do not call `setTraceId`
|
|
543
524
|
* from request-handling code.
|
|
544
525
|
*/
|
|
545
|
-
declare function setTraceId(traceId: string, data?: Record<string, unknown>): void;
|
|
526
|
+
export declare function setTraceId(traceId: string, data?: Record<string, unknown>): void;
|
|
546
527
|
/** Run `fn` inside a new async context carrying `traceId`. */
|
|
547
|
-
declare function runWithTraceId<T>(traceId: string, fn: () => T, data?: Record<string, unknown>): T;
|
|
528
|
+
export declare function runWithTraceId<T>(traceId: string, fn: () => T, data?: Record<string, unknown>): T;
|
|
548
529
|
/** Maximum accepted length for an incoming trace / correlation / request ID. */
|
|
549
|
-
declare const MAX_INCOMING_ID_LENGTH = 128;
|
|
530
|
+
export declare const MAX_INCOMING_ID_LENGTH = 128;
|
|
550
531
|
/**
|
|
551
532
|
* Validate an externally supplied identifier (trace ID, correlation ID, origin
|
|
552
533
|
* service name, message-queue ID). Accepts only 1-128 characters from
|
|
@@ -554,20 +535,18 @@ declare const MAX_INCOMING_ID_LENGTH = 128;
|
|
|
554
535
|
* first element. Returns the cleaned value, or `undefined` when it is unusable
|
|
555
536
|
* so callers can generate a fresh ID instead of passing client text through.
|
|
556
537
|
*/
|
|
557
|
-
declare function sanitizeIncomingId(value: unknown): string | undefined;
|
|
538
|
+
export declare function sanitizeIncomingId(value: unknown): string | undefined;
|
|
558
539
|
/** Extract trace ID from request using configuration (header → query → body → params). */
|
|
559
|
-
declare function extractTraceId(request: unknown, config: TraceIdExtractorConfig): string | undefined;
|
|
540
|
+
export declare function extractTraceId(request: unknown, config: TraceIdExtractorConfig): string | undefined;
|
|
560
541
|
/**
|
|
561
542
|
* Default headers checked for incoming trace ID propagation, in priority order:
|
|
562
543
|
* traceparent (W3C/OTel) → x-trace-id → x-request-id → x-correlation-id → trace-id
|
|
563
544
|
*/
|
|
564
|
-
declare const DEFAULT_TRACE_HEADERS: string[];
|
|
545
|
+
export declare const DEFAULT_TRACE_HEADERS: string[];
|
|
565
546
|
/**
|
|
566
547
|
* Create trace ID middleware for Express/NestJS
|
|
567
548
|
*/
|
|
568
|
-
declare function createTraceMiddleware(config: TraceIdConfig): (req: unknown, res: unknown, next: () => void) => void;
|
|
569
|
-
//#endregion
|
|
570
|
-
//#region src/utils/typed-logger.d.ts
|
|
549
|
+
export declare function createTraceMiddleware(config: TraceIdConfig): (req: unknown, res: unknown, next: () => void) => void;
|
|
571
550
|
/**
|
|
572
551
|
* logixia — TypeScript typed log fields
|
|
573
552
|
*
|
|
@@ -616,8 +595,8 @@ interface LogFieldDef {
|
|
|
616
595
|
/** Custom validator — return a string to emit it as a warning message. */
|
|
617
596
|
validate?: (value: unknown) => string | undefined;
|
|
618
597
|
}
|
|
619
|
-
type LogSchema<TFields extends
|
|
620
|
-
interface CompiledSchema<TFields extends
|
|
598
|
+
type LogSchema<TFields extends object> = { [K in keyof TFields]: LogFieldDef; };
|
|
599
|
+
interface CompiledSchema<TFields extends object> {
|
|
621
600
|
readonly fields: LogSchema<TFields>;
|
|
622
601
|
/**
|
|
623
602
|
* Validate a payload against the schema.
|
|
@@ -632,7 +611,7 @@ interface CompiledSchema<TFields extends Record<string, unknown>> {
|
|
|
632
611
|
* Call this once at module initialisation and pass it to `createTypedLogger`.
|
|
633
612
|
* In development, every log call is validated against the schema.
|
|
634
613
|
*/
|
|
635
|
-
declare function defineLogSchema<TFields extends
|
|
614
|
+
export declare function defineLogSchema<TFields extends object>(fields: LogSchema<TFields>): CompiledSchema<TFields>;
|
|
636
615
|
/** IBaseLogger-compatible subset used by TypedLogger */
|
|
637
616
|
interface LoggerLike {
|
|
638
617
|
error(message: string | Error, data?: Record<string, unknown>): Promise<void>;
|
|
@@ -648,7 +627,7 @@ interface LoggerLike {
|
|
|
648
627
|
* The `error` overload still accepts a plain `Error` object as the first arg
|
|
649
628
|
* (with optional `TFields` data) so the typed logger remains a drop-in replacement.
|
|
650
629
|
*/
|
|
651
|
-
interface TypedLogger<TFields extends
|
|
630
|
+
interface TypedLogger<TFields extends object> {
|
|
652
631
|
error(error: Error, data?: Partial<TFields>): Promise<void>;
|
|
653
632
|
error(message: string, data?: Partial<TFields>): Promise<void>;
|
|
654
633
|
warn(message: string, data?: Partial<TFields>): Promise<void>;
|
|
@@ -665,42 +644,7 @@ interface TypedLogger<TFields extends Record<string, unknown>> {
|
|
|
665
644
|
* @param logger Any object that implements `IBaseLogger` (e.g. the result of `createLogger()`)
|
|
666
645
|
* @param schema Optional schema for dev-time validation. Created with `defineLogSchema()`.
|
|
667
646
|
*/
|
|
668
|
-
declare function createTypedLogger<TFields extends
|
|
669
|
-
//#endregion
|
|
670
|
-
//#region src/wide-events.d.ts
|
|
671
|
-
/**
|
|
672
|
-
* logixia — Canonical Log Lines / Wide Events.
|
|
673
|
-
*
|
|
674
|
-
* Emit ONE dense, structured event per unit of work (usually a request) instead
|
|
675
|
-
* of scattering details across many narrow log lines. Fields are accumulated as
|
|
676
|
-
* the request flows through middleware and business logic, then the whole event
|
|
677
|
-
* is emitted ONCE — in a `finally`/teardown path so it fires even on errors.
|
|
678
|
-
*
|
|
679
|
-
* This is the "canonical log line" pattern (Stripe) / "wide events" /
|
|
680
|
-
* "Observability 2.0" (Honeycomb): one pre-joined, queryable record per request,
|
|
681
|
-
* so operators never JOIN across log lines during an incident. It composes with
|
|
682
|
-
* logixia's existing trace correlation — when a trace is active, the event
|
|
683
|
-
* carries `traceId`/`spanId`, making it OTel-friendly.
|
|
684
|
-
*
|
|
685
|
-
* @example Manual scope
|
|
686
|
-
* ```ts
|
|
687
|
-
* import { withWideEvent, addEventFields } from 'logixia';
|
|
688
|
-
*
|
|
689
|
-
* await withWideEvent(logger, { route: '/checkout' }, async () => {
|
|
690
|
-
* addEventFields({ userId, planTier }); // from anywhere in the call tree
|
|
691
|
-
* addEventFields({ dbQueries: 4, cacheHit });
|
|
692
|
-
* // ...one wide event is emitted automatically when this callback settles,
|
|
693
|
-
* // even if it throws.
|
|
694
|
-
* });
|
|
695
|
-
* ```
|
|
696
|
-
*
|
|
697
|
-
* @example Express middleware (auto-emit on response finish/close)
|
|
698
|
-
* ```ts
|
|
699
|
-
* import { wideEventMiddleware } from 'logixia';
|
|
700
|
-
* app.use(wideEventMiddleware(logger));
|
|
701
|
-
* app.get('/x', (req, res) => { addEventFields({ handled: 'x' }); res.json({}); });
|
|
702
|
-
* ```
|
|
703
|
-
*/
|
|
647
|
+
export declare function createTypedLogger<TFields extends object>(logger: LoggerLike, schema?: CompiledSchema<TFields>): TypedLogger<TFields>;
|
|
704
648
|
/** The accumulating event fields for the current scope. */
|
|
705
649
|
type WideEventFields = Record<string, unknown>;
|
|
706
650
|
/** Minimal logger surface a wide event needs to emit itself. */
|
|
@@ -725,35 +669,29 @@ interface WideEventOptions {
|
|
|
725
669
|
* throw) when called outside a `withWideEvent` / middleware scope, so business
|
|
726
670
|
* code can call it unconditionally.
|
|
727
671
|
*/
|
|
728
|
-
declare function addEventFields(fields: WideEventFields): void;
|
|
672
|
+
export declare function addEventFields(fields: WideEventFields): void;
|
|
729
673
|
/** Set a single field on the current wide event. */
|
|
730
|
-
declare function setEventField(key: string, value: unknown): void;
|
|
674
|
+
export declare function setEventField(key: string, value: unknown): void;
|
|
731
675
|
/** Read a shallow copy of the wide event accumulated so far, or undefined. */
|
|
732
|
-
declare function getEventFields(): WideEventFields | undefined;
|
|
676
|
+
export declare function getEventFields(): WideEventFields | undefined;
|
|
733
677
|
/**
|
|
734
678
|
* Run `callback` inside a wide-event scope. `addEventFields` calls anywhere in
|
|
735
679
|
* the (async) call tree accumulate onto one event, which is emitted exactly once
|
|
736
680
|
* when the callback settles — on success OR error (the canonical "emit in
|
|
737
681
|
* finally" guarantee). On error, `error` + `errorMessage` fields are added.
|
|
738
682
|
*/
|
|
739
|
-
declare function withWideEvent<T>(logger: WideEventLogger, initialFields: WideEventFields, callback: () => Promise<T> | T, options?: WideEventOptions): Promise<T>;
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
url?: string | undefined;
|
|
743
|
-
originalUrl?: string | undefined;
|
|
744
|
-
ip?: string | undefined;
|
|
745
|
-
headers?: Record<string, unknown> | undefined;
|
|
746
|
-
socket?: {
|
|
747
|
-
remoteAddress?: string;
|
|
748
|
-
} | undefined;
|
|
749
|
-
}
|
|
750
|
-
interface MwRes {
|
|
751
|
-
statusCode?: number;
|
|
752
|
-
once?: (event: string, cb: () => void) => void;
|
|
753
|
-
}
|
|
683
|
+
export declare function withWideEvent<T>(logger: WideEventLogger, initialFields: WideEventFields, callback: () => Promise<T> | T, options?: WideEventOptions): Promise<T>;
|
|
684
|
+
type MwReq = HttpRequestShape;
|
|
685
|
+
type MwRes = HttpResponseShape;
|
|
754
686
|
interface WideEventMiddlewareOptions extends WideEventOptions {
|
|
755
687
|
/** Derive extra initial fields from the request. */
|
|
756
688
|
enrich?: (req: MwReq) => WideEventFields;
|
|
689
|
+
/**
|
|
690
|
+
* Additional query-string parameter names whose values are redacted from the
|
|
691
|
+
* logged `url`. Merged with the defaults (token, access_token, refresh_token,
|
|
692
|
+
* code, password, secret, api_key, apikey, key, signature, sig, auth).
|
|
693
|
+
*/
|
|
694
|
+
redactQueryParams?: string[];
|
|
757
695
|
/** Skip wide-event emission for a request (e.g. health checks). */
|
|
758
696
|
skip?: (req: MwReq) => boolean;
|
|
759
697
|
}
|
|
@@ -764,63 +702,10 @@ interface WideEventMiddlewareOptions extends WideEventOptions {
|
|
|
764
702
|
* more via `addEventFields`. The completion event includes `statusCode` and the
|
|
765
703
|
* request duration.
|
|
766
704
|
*/
|
|
767
|
-
declare function wideEventMiddleware(logger: WideEventLogger, options?: WideEventMiddlewareOptions): (req: MwReq, res: MwRes, next: () => void) => void;
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
/** OTLP/HTTP logs endpoint, e.g. `http://localhost:4318/v1/logs`. */
|
|
772
|
-
url: string;
|
|
773
|
-
/** Extra HTTP headers (auth, tenant, etc.). */
|
|
774
|
-
headers?: Record<string, string>;
|
|
775
|
-
/** `service.name` resource attribute. Default: 'logixia'. */
|
|
776
|
-
serviceName?: string;
|
|
777
|
-
/** `service.version` resource attribute. */
|
|
778
|
-
serviceVersion?: string;
|
|
779
|
-
/** `deployment.environment` resource attribute. */
|
|
780
|
-
environment?: string;
|
|
781
|
-
/** Extra resource attributes merged into the OTLP resource. */
|
|
782
|
-
resourceAttributes?: Record<string, string | number | boolean>;
|
|
783
|
-
/** Entries per batch / per POST. Default: 100. */
|
|
784
|
-
batchSize?: number;
|
|
785
|
-
/** Auto-flush interval (ms). Default: 5000. */
|
|
786
|
-
flushIntervalMs?: number;
|
|
787
|
-
/** Abort a request that has not finished after this many ms. Default: 10000. */
|
|
788
|
-
requestTimeoutMs?: number;
|
|
789
|
-
/** Max buffered entries; the oldest are dropped past this. Default: 10000. */
|
|
790
|
-
maxBufferSize?: number;
|
|
791
|
-
level?: string;
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Map a logixia level name to an OTel SeverityNumber (1–24) and text.
|
|
795
|
-
* Per the OTel logs SDK spec: TRACE=1, DEBUG=5, INFO=9, WARN=13, ERROR=17,
|
|
796
|
-
* FATAL=21. Custom/unknown levels fall back to INFO (9).
|
|
797
|
-
*/
|
|
798
|
-
declare function toOtelSeverity(level: string): {
|
|
799
|
-
number: number;
|
|
800
|
-
text: string;
|
|
801
|
-
};
|
|
802
|
-
declare class OtlpLogTransport implements IAsyncTransport {
|
|
803
|
-
readonly name = "otlp";
|
|
804
|
-
readonly level: string | undefined;
|
|
805
|
-
private readonly url;
|
|
806
|
-
private readonly headers;
|
|
807
|
-
private readonly batchSize;
|
|
808
|
-
private readonly flushIntervalMs;
|
|
809
|
-
private readonly requestTimeoutMs;
|
|
810
|
-
private readonly resourceAttrs;
|
|
811
|
-
private readonly buffer;
|
|
812
|
-
private flushTimer;
|
|
813
|
-
constructor(config: OtlpLogTransportConfig);
|
|
814
|
-
write(entry: TransportLogEntry): void;
|
|
815
|
-
/** Convert one entry into an OTLP LogRecord. */
|
|
816
|
-
private toLogRecord;
|
|
817
|
-
private buildPayload;
|
|
818
|
-
flush(): Promise<void>;
|
|
819
|
-
private send;
|
|
820
|
-
close(): Promise<void>;
|
|
821
|
-
}
|
|
822
|
-
//#endregion
|
|
823
|
-
//#region src/context/async-context.d.ts
|
|
705
|
+
export declare function wideEventMiddleware(logger: WideEventLogger, options?: WideEventMiddlewareOptions): (req: MwReq, res: MwRes, next: () => void) => void;
|
|
706
|
+
type TraceHeaderOption = string | readonly string[];
|
|
707
|
+
/** Minimal structural request shape; Express and Fastify requests satisfy it. */
|
|
708
|
+
type ContextRequestLike = HttpRequestShape;
|
|
824
709
|
interface LogContext {
|
|
825
710
|
traceId?: string;
|
|
826
711
|
spanId?: string;
|
|
@@ -829,7 +714,7 @@ interface LogContext {
|
|
|
829
714
|
sessionId?: string;
|
|
830
715
|
[key: string]: unknown;
|
|
831
716
|
}
|
|
832
|
-
declare const LogixiaContext: {
|
|
717
|
+
export declare const LogixiaContext: {
|
|
833
718
|
/**
|
|
834
719
|
* Run `callback` inside an async context that carries `store` fields.
|
|
835
720
|
* All loggers queried within `callback` (and its async descendants) will
|
|
@@ -859,33 +744,53 @@ declare const LogixiaContext: {
|
|
|
859
744
|
*/
|
|
860
745
|
getStorage(): AsyncLocalStorage<LogContext>;
|
|
861
746
|
};
|
|
747
|
+
interface ContextHelperOptions<Req extends ContextRequestLike> {
|
|
748
|
+
/**
|
|
749
|
+
* Extract additional fields from the request. A `traceId` returned here is ignored:
|
|
750
|
+
* the resolved request trace ID always wins.
|
|
751
|
+
*/
|
|
752
|
+
enrich?: (request: Req & Record<string, unknown>) => Partial<LogContext>;
|
|
753
|
+
/**
|
|
754
|
+
* Header name, or list of names tried in order, to read the trace ID from.
|
|
755
|
+
* Default: `DEFAULT_TRACE_HEADERS` (traceparent is parsed to its 32-hex trace id).
|
|
756
|
+
*/
|
|
757
|
+
traceIdHeader?: TraceHeaderOption;
|
|
758
|
+
/**
|
|
759
|
+
* Echo the resolved trace ID on the response under this header name.
|
|
760
|
+
* Default: `false` (no response header is set).
|
|
761
|
+
*/
|
|
762
|
+
responseHeader?: string | false;
|
|
763
|
+
}
|
|
862
764
|
/**
|
|
863
765
|
* Create an Express/Connect-compatible middleware that wraps each request in
|
|
864
766
|
* a `LogixiaContext.run()` scope populated with common request fields.
|
|
865
767
|
*
|
|
768
|
+
* Trace ID: the first present header of `traceIdHeader` (default
|
|
769
|
+
* `DEFAULT_TRACE_HEADERS`, `traceparent` parsed), else `request.id`, else a
|
|
770
|
+
* generated UUID. It is available via `getCurrentTraceId()` and is the logger's
|
|
771
|
+
* top-level `traceId` inside the request. No response header is set unless
|
|
772
|
+
* `responseHeader` is given.
|
|
773
|
+
*
|
|
866
774
|
* @example
|
|
867
775
|
* ```ts
|
|
868
776
|
* import { createExpressContextMiddleware } from 'logixia';
|
|
869
|
-
* app.use(createExpressContextMiddleware());
|
|
777
|
+
* app.use(createExpressContextMiddleware({ responseHeader: 'x-trace-id' }));
|
|
870
778
|
* ```
|
|
871
779
|
*/
|
|
872
|
-
declare function createExpressContextMiddleware(options?: {
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
/** Header to read the traceId from. Default: 'x-trace-id'. */
|
|
876
|
-
traceIdHeader?: string;
|
|
877
|
-
}): (req: Record<string, unknown>, _res: unknown, next: () => void) => void;
|
|
780
|
+
export declare function createExpressContextMiddleware<Req extends ContextRequestLike = ContextRequestLike>(options?: ContextHelperOptions<Req>): (req: Req, res: {
|
|
781
|
+
setHeader?: (name: string, value: string) => unknown;
|
|
782
|
+
}, next: () => void) => void;
|
|
878
783
|
/**
|
|
879
784
|
* Create a Fastify lifecycle hook that wraps each request in a context scope.
|
|
880
785
|
*
|
|
881
786
|
* Register with `fastify.addHook('onRequest', createFastifyContextHook())`.
|
|
787
|
+
* Resolves the trace ID exactly like {@link createExpressContextMiddleware} and
|
|
788
|
+
* shares it with `createFastifyPlugin()` from `logixia/middleware`. Fastify's
|
|
789
|
+
* default counter `request.id` (`req-1`, ...) is never used as a trace ID.
|
|
882
790
|
*/
|
|
883
|
-
declare function createFastifyContextHook(options?: {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
}): (request: Record<string, unknown>, _reply: unknown, done: () => void) => void;
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region src/utils/sampling.utils.d.ts
|
|
791
|
+
export declare function createFastifyContextHook<Req extends ContextRequestLike = ContextRequestLike>(options?: ContextHelperOptions<Req>): (request: Req, reply: {
|
|
792
|
+
header?: (name: string, value: string) => unknown;
|
|
793
|
+
}, done: () => void) => void;
|
|
889
794
|
interface SamplingStats {
|
|
890
795
|
/** Total calls evaluated since last reset. */
|
|
891
796
|
evaluated: number;
|
|
@@ -901,8 +806,6 @@ interface SamplingStats {
|
|
|
901
806
|
/** Window start (ms since epoch). */
|
|
902
807
|
windowStart: number;
|
|
903
808
|
}
|
|
904
|
-
//#endregion
|
|
905
|
-
//#region src/exceptions/types.d.ts
|
|
906
809
|
/**
|
|
907
810
|
* Unified error response shape for logixia.
|
|
908
811
|
*
|
|
@@ -1010,8 +913,6 @@ interface ErrorDetail {
|
|
|
1010
913
|
*/
|
|
1011
914
|
code: string;
|
|
1012
915
|
}
|
|
1013
|
-
//#endregion
|
|
1014
|
-
//#region src/exceptions/builder.d.ts
|
|
1015
916
|
/** Input parameters for `ErrorResponseBuilder.build`. */
|
|
1016
917
|
interface BuildParams {
|
|
1017
918
|
/** The caught exception — any type. */
|
|
@@ -1057,10 +958,10 @@ interface BuildParams {
|
|
|
1057
958
|
*
|
|
1058
959
|
* @example `'550e8400-e29b-41d4-a716-446655440000'`
|
|
1059
960
|
*/
|
|
1060
|
-
declare function generateTraceId(): string;
|
|
961
|
+
export declare function generateTraceId(): string;
|
|
1061
962
|
/** @deprecated Use `generateTraceId` instead. */
|
|
1062
|
-
declare const generateRequestId: typeof generateTraceId;
|
|
1063
|
-
declare class ErrorResponseBuilder {
|
|
963
|
+
export declare const generateRequestId: typeof generateTraceId;
|
|
964
|
+
export declare class ErrorResponseBuilder {
|
|
1064
965
|
/**
|
|
1065
966
|
* Build a `LogixiaErrorResponse` from any thrown value.
|
|
1066
967
|
*
|
|
@@ -1097,8 +998,6 @@ declare class ErrorResponseBuilder {
|
|
|
1097
998
|
httpStatus: number;
|
|
1098
999
|
};
|
|
1099
1000
|
}
|
|
1100
|
-
//#endregion
|
|
1101
|
-
//#region src/exceptions/exception.d.ts
|
|
1102
1001
|
/**
|
|
1103
1002
|
* Constructor options for `LogixiaException`.
|
|
1104
1003
|
*
|
|
@@ -1158,7 +1057,7 @@ interface LogixiaExceptionOptions<TCode extends string = string, TType extends s
|
|
|
1158
1057
|
*/
|
|
1159
1058
|
metadata?: Record<string, unknown>;
|
|
1160
1059
|
}
|
|
1161
|
-
declare class LogixiaException<TCode extends string = string, TType extends string = string> extends Error {
|
|
1060
|
+
export declare class LogixiaException<TCode extends string = string, TType extends string = string> extends Error {
|
|
1162
1061
|
/** @readonly The machine-readable error code supplied by the caller. */
|
|
1163
1062
|
readonly errorCode: TCode;
|
|
1164
1063
|
/** @readonly The error type category supplied by the caller. */
|
|
@@ -1190,9 +1089,7 @@ declare class LogixiaException<TCode extends string = string, TType extends stri
|
|
|
1190
1089
|
* }
|
|
1191
1090
|
* ```
|
|
1192
1091
|
*/
|
|
1193
|
-
declare function isLogixiaException<TCode extends string = string, TType extends string = string>(value?: unknown): value is LogixiaException<TCode, TType>;
|
|
1194
|
-
//#endregion
|
|
1195
|
-
//#region src/metrics.d.ts
|
|
1092
|
+
export declare function isLogixiaException<TCode extends string = string, TType extends string = string>(value?: unknown): value is LogixiaException<TCode, TType>;
|
|
1196
1093
|
/**
|
|
1197
1094
|
* Increment a counter on each matching log entry.
|
|
1198
1095
|
*
|
|
@@ -1265,7 +1162,7 @@ interface GaugeConfig {
|
|
|
1265
1162
|
type MetricConfig = CounterConfig | HistogramConfig | GaugeConfig;
|
|
1266
1163
|
type MetricsMap = Record<string, MetricConfig>;
|
|
1267
1164
|
/** Label value used for the series that absorbs label sets beyond the cardinality cap. */
|
|
1268
|
-
declare const OVERFLOW_LABEL_VALUE = "__overflow__";
|
|
1165
|
+
export declare const OVERFLOW_LABEL_VALUE = "__overflow__";
|
|
1269
1166
|
interface MetricsPluginOptions {
|
|
1270
1167
|
/**
|
|
1271
1168
|
* Maximum number of distinct label sets tracked per metric. Once reached, new
|
|
@@ -1291,7 +1188,7 @@ interface MetricsPluginOptions {
|
|
|
1291
1188
|
* logger.use(metrics);
|
|
1292
1189
|
* ```
|
|
1293
1190
|
*/
|
|
1294
|
-
declare class MetricsPlugin implements LogixiaPlugin {
|
|
1191
|
+
export declare class MetricsPlugin implements LogixiaPlugin {
|
|
1295
1192
|
readonly name = "logixia-metrics";
|
|
1296
1193
|
private readonly map;
|
|
1297
1194
|
private readonly metricState;
|
|
@@ -1382,19 +1279,17 @@ declare class MetricsPlugin implements LogixiaPlugin {
|
|
|
1382
1279
|
*
|
|
1383
1280
|
* Pass `{ maxLabelSets }` to change the per-metric label cardinality cap (default 1000).
|
|
1384
1281
|
*/
|
|
1385
|
-
declare function createMetricsPlugin(map: MetricsMap, options?: MetricsPluginOptions): MetricsPlugin;
|
|
1386
|
-
//#endregion
|
|
1387
|
-
//#region src/index.d.ts
|
|
1282
|
+
export declare function createMetricsPlugin(map: MetricsMap, options?: MetricsPluginOptions): MetricsPlugin;
|
|
1388
1283
|
/**
|
|
1389
1284
|
* Create a new Logixia logger instance with TypeScript support for custom levels
|
|
1390
1285
|
* @param config - Logger configuration
|
|
1391
1286
|
* @returns Typed logger instance
|
|
1392
1287
|
*/
|
|
1393
|
-
declare const createLogger: typeof createLogger$1;
|
|
1288
|
+
export declare const createLogger: typeof createLogger$1;
|
|
1394
1289
|
/**
|
|
1395
1290
|
* Default logger instance
|
|
1396
1291
|
*/
|
|
1397
|
-
declare const logger: LogixiaLogger<{
|
|
1292
|
+
export declare const logger: LogixiaLogger<{
|
|
1398
1293
|
appName: string;
|
|
1399
1294
|
environment: Environment;
|
|
1400
1295
|
traceId: boolean;
|
|
@@ -1427,6 +1322,8 @@ declare const logger: LogixiaLogger<{
|
|
|
1427
1322
|
};
|
|
1428
1323
|
outputs: string[];
|
|
1429
1324
|
}>;
|
|
1430
|
-
|
|
1431
|
-
|
|
1325
|
+
/**
|
|
1326
|
+
* Export default configuration for reference
|
|
1327
|
+
*/
|
|
1328
|
+
export { AdaptiveSamplingConfig, type AnomalyDetection, BasicLogIndexer, BasicSearchEngine, type BuildParams, type CompiledSchema, ContextData, type CorrelatedLogs, CorrelationEngine, type CounterConfig, CustomLevelMethods, DEFAULT_LOG_COLORS, DEFAULT_LOG_LEVELS, type DiscordEmbed, DiscordTransport, type DiscordTransportConfig, type EntityType, Environment, type ErrorDetail, ErrorSerializationOptions, type ExportOptions, ExtractLevels, type GaugeConfig, GracefulShutdownConfig, type HistogramConfig, HttpError, HttpRequest, HttpResponse, IBaseLogger, ILogFormatter, type ILogIndexer, type ILogSearchEngine, ILogger, ILoggerDefault, ILoggerRuntimeControls, type ITransport, type LevelSignalOptions, type LogCluster, LogColor, type LogContext, type LogCorrelationSummary, LogEntry, type LogFieldDef, LogFieldKey, type LogFieldType, LogLevel, LogLevelString, type LogPattern, type LogSchema, LoggerConfig, type LoggerConfig as LoggerConfigInterface, type LoggerLike, LoggerWithLevels, type LogixiaErrorResponse, type LogixiaExceptionOptions, LogixiaLogger, LogixiaLoggerDefault, LogixiaLoggerInstance, type LogixiaPlugin, type MetricConfig, type MetricsMap, type MetricsPluginOptions, NLPSearchEngine, NamespaceLevels, type OtelBridgeOptions, type OtelSpanContext, OtlpLogTransport, type OtlpLogTransportConfig, type ParsedNLQuery, PatternRecognitionEngine, PluginRegistry, type QueryEntity, type QueryIntent, type ReconfigurableLogger, RedactConfig, type RelatedLog, type RelationshipType, type RelativeTime, RequestContext, RequestMetrics, RequestTiming, ReservedLevelName, type SafeStringifyOptions, SamplingConfig, type SamplingStats, type SearchFilters, type SearchHighlight, SearchManager, type SearchManagerConfig, type SearchMatch, type SearchOptions, type SearchPreset, type SearchQuery, type SearchResult, type SearchStats, type SearchSuggestion, type SemanticIndex, type SimilarLog, type SlackMessage, SlackTransport, type SlackTransportConfig, type SortField, type SuggestionType, type TimeRange, type TimelineEvent, TimingEntry, TraceIdConfig, TraceIdExtractorConfig, type TransportConfig, type TransportLogEntry, type TypedLogger, type WideEventFields, type WideEventLogger, type WideEventMiddlewareOptions, type WideEventOptions, globalPluginRegistry, toOtelSeverity, usePlugin };
|
|
1432
1329
|
//# sourceMappingURL=index.d.mts.map
|