@x12i/logxer 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1255 -0
  3. package/dist/app-info.d.ts +25 -0
  4. package/dist/app-info.d.ts.map +1 -0
  5. package/dist/app-info.js +179 -0
  6. package/dist/app-info.js.map +1 -0
  7. package/dist/formatters/table-formatter.d.ts +23 -0
  8. package/dist/formatters/table-formatter.d.ts.map +1 -0
  9. package/dist/formatters/table-formatter.js +218 -0
  10. package/dist/formatters/table-formatter.js.map +1 -0
  11. package/dist/formatters/yaml-formatter.d.ts +14 -0
  12. package/dist/formatters/yaml-formatter.d.ts.map +1 -0
  13. package/dist/formatters/yaml-formatter.js +164 -0
  14. package/dist/formatters/yaml-formatter.js.map +1 -0
  15. package/dist/index.d.ts +44 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +219 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/logxer.d.ts +145 -0
  20. package/dist/logxer.d.ts.map +1 -0
  21. package/dist/logxer.js +811 -0
  22. package/dist/logxer.js.map +1 -0
  23. package/dist/outputs/shadow-sink.d.ts +83 -0
  24. package/dist/outputs/shadow-sink.d.ts.map +1 -0
  25. package/dist/outputs/shadow-sink.js +380 -0
  26. package/dist/outputs/shadow-sink.js.map +1 -0
  27. package/dist/outputs/unified-logger-output.d.ts +30 -0
  28. package/dist/outputs/unified-logger-output.d.ts.map +1 -0
  29. package/dist/outputs/unified-logger-output.js +125 -0
  30. package/dist/outputs/unified-logger-output.js.map +1 -0
  31. package/dist/sanitizer.d.ts +69 -0
  32. package/dist/sanitizer.d.ts.map +1 -0
  33. package/dist/sanitizer.js +507 -0
  34. package/dist/sanitizer.js.map +1 -0
  35. package/dist/trails/headers.d.ts +21 -0
  36. package/dist/trails/headers.d.ts.map +1 -0
  37. package/dist/trails/headers.js +121 -0
  38. package/dist/trails/headers.js.map +1 -0
  39. package/dist/trails/index.d.ts +59 -0
  40. package/dist/trails/index.d.ts.map +1 -0
  41. package/dist/trails/index.js +197 -0
  42. package/dist/trails/index.js.map +1 -0
  43. package/dist/types.d.ts +411 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +8 -0
  46. package/dist/types.js.map +1 -0
  47. package/dist/utils/debug-config.d.ts +19 -0
  48. package/dist/utils/debug-config.d.ts.map +1 -0
  49. package/dist/utils/debug-config.js +172 -0
  50. package/dist/utils/debug-config.js.map +1 -0
  51. package/dist/utils/package-logs-level.d.ts +40 -0
  52. package/dist/utils/package-logs-level.d.ts.map +1 -0
  53. package/dist/utils/package-logs-level.js +79 -0
  54. package/dist/utils/package-logs-level.js.map +1 -0
  55. package/docs/package-usage.md +155 -0
  56. package/docs/package.md +48 -0
  57. package/docs/upgrade-for-package-authors.md +85 -0
  58. package/package.json +98 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/trails/headers.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAOH,kDA8BC;AAKD,oDA+CC;AAKD,wDAcC;AAKD,0DAqCC;AAlJD;;GAEG;AACH,SAAgB,mBAAmB,CACjC,OAA+B,EAC/B,OAAsB;IAEtB,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC1C,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IAEpD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;YACrD,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;YAC/B,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QACxB,OAAO,CAAC,gBAAgB,CAAC,G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AC,CAAC;IACxC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * AsyncLocalStorage-based trails module for operation and thread tracking
3
+ */
4
+ import type { OperationCtx, ThreadContext } from '../types';
5
+ /**
6
+ * Operation scope for managing operation lifecycle
7
+ */
8
+ export declare class OperationScope {
9
+ private readonly operationId;
10
+ private readonly parentOperationId?;
11
+ private readonly operationName;
12
+ private readonly operationPath;
13
+ private readonly operationStep;
14
+ private readonly traceId;
15
+ private readonly spanId;
16
+ private ended;
17
+ constructor(operationId: string, parentOperationId: string | undefined, operationName: string, operationPath: string, operationStep: number, traceId: string, spanId: string);
18
+ /**
19
+ * End the operation scope
20
+ */
21
+ end(_resultAttrs?: Record<string, any>): void;
22
+ /**
23
+ * Execute a function within this operation scope
24
+ */
25
+ with<T>(fn: () => T | Promise<T>): Promise<T>;
26
+ }
27
+ /**
28
+ * Start a new operation scope
29
+ */
30
+ export declare function startOperation(name: string, _attrs?: Record<string, any>): OperationScope;
31
+ /**
32
+ * Create a child operation scope
33
+ */
34
+ export declare function childOperation(name: string, _attrs?: Record<string, any>): OperationScope;
35
+ /**
36
+ * Get the current operation context
37
+ */
38
+ export declare function getCurrentOperation(): OperationCtx | null;
39
+ /**
40
+ * Create a new thread context
41
+ */
42
+ export declare function newThread(init?: Partial<ThreadContext>): ThreadContext;
43
+ /**
44
+ * Continue an existing thread context
45
+ */
46
+ export declare function continueThread(ctx: Partial<ThreadContext>): ThreadContext;
47
+ /**
48
+ * Generate the next event ID and increment sequence
49
+ */
50
+ export declare function nextEventId(): string;
51
+ /**
52
+ * Get the current thread context
53
+ */
54
+ export declare function getCurrentThread(): ThreadContext | null;
55
+ /**
56
+ * Clear all contexts (for testing)
57
+ */
58
+ export declare function clearAllContexts(): void;
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trails/index.ts"],"names":[],"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wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAkBtE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAmBzE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAqBpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CAEvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ /**
3
+ * AsyncLocalStorage-based trails module for operation and thread tracking
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OperationScope = void 0;
7
+ exports.startOperation = startOperation;
8
+ exports.childOperation = childOperation;
9
+ exports.getCurrentOperation = getCurrentOperation;
10
+ exports.newThread = newThread;
11
+ exports.continueThread = continueThread;
12
+ exports.nextEventId = nextEventId;
13
+ exports.getCurrentThread = getCurrentThread;
14
+ exports.clearAllContexts = clearAllContexts;
15
+ const async_hooks_1 = require("async_hooks");
16
+ const nanoid_1 = require("nanoid");
17
+ // AsyncLocalStorage stores for context preservation
18
+ const operationStore = new async_hooks_1.AsyncLocalStorage();
19
+ const threadStore = new async_hooks_1.AsyncLocalStorage();
20
+ /**
21
+ * Operation scope for managing operation lifecycle
22
+ */
23
+ class OperationScope {
24
+ constructor(operationId, parentOperationId, operationName, operationPath, operationStep, traceId, spanId) {
25
+ this.ended = false;
26
+ this.operationId = operationId;
27
+ this.parentOperationId = parentOperationId || undefined;
28
+ this.operationName = operationName;
29
+ this.operationPath = operationPath;
30
+ this.operationStep = operationStep;
31
+ this.traceId = traceId;
32
+ this.spanId = spanId;
33
+ }
34
+ /**
35
+ * End the operation scope
36
+ */
37
+ end(_resultAttrs) {
38
+ if (this.ended) {
39
+ return;
40
+ }
41
+ this.ended = true;
42
+ // Clear the operation context by setting it to null
43
+ operationStore.enterWith(null);
44
+ }
45
+ /**
46
+ * Execute a function within this operation scope
47
+ */
48
+ async with(fn) {
49
+ const context = {
50
+ operationId: this.operationId,
51
+ parentOperationId: this.parentOperationId,
52
+ operationName: this.operationName,
53
+ operationPath: this.operationPath,
54
+ operationStep: this.operationStep,
55
+ traceId: this.traceId,
56
+ spanId: this.spanId
57
+ };
58
+ return operationStore.run(context, fn);
59
+ }
60
+ }
61
+ exports.OperationScope = OperationScope;
62
+ /**
63
+ * Start a new operation scope
64
+ */
65
+ function startOperation(name, _attrs) {
66
+ const parentCtx = getCurrentOperation();
67
+ const operationId = (0, nanoid_1.nanoid)(12);
68
+ const traceId = parentCtx?.traceId || (0, nanoid_1.nanoid)(16);
69
+ const spanId = (0, nanoid_1.nanoid)(12);
70
+ const operationPath = parentCtx
71
+ ? `${parentCtx.operationPath}.${name}`
72
+ : name;
73
+ const operationStep = 0; // Root operations start at step 0
74
+ const scope = new OperationScope(operationId, parentCtx?.operationId, name, operationPath, operationStep, traceId, spanId);
75
+ // Set the context immediately
76
+ const context = {
77
+ operationId,
78
+ parentOperationId: parentCtx?.operationId,
79
+ operationName: name,
80
+ operationPath,
81
+ operationStep,
82
+ traceId,
83
+ spanId
84
+ };
85
+ operationStore.enterWith(context);
86
+ return scope;
87
+ }
88
+ /**
89
+ * Create a child operation scope
90
+ */
91
+ function childOperation(name, _attrs) {
92
+ const parentCtx = getCurrentOperation();
93
+ if (!parentCtx) {
94
+ throw new Error('No parent operation context available. Call startOperation() first.');
95
+ }
96
+ const operationId = (0, nanoid_1.nanoid)(12);
97
+ const traceId = parentCtx.traceId;
98
+ const spanId = (0, nanoid_1.nanoid)(12);
99
+ const operationPath = `${parentCtx.operationPath}.${name}`;
100
+ const operationStep = parentCtx.operationStep + 1;
101
+ const scope = new OperationScope(operationId, parentCtx.operationId, name, operationPath, operationStep, traceId, spanId);
102
+ // Set the context immediately
103
+ const context = {
104
+ operationId,
105
+ parentOperationId: parentCtx.operationId,
106
+ operationName: name,
107
+ operationPath,
108
+ operationStep,
109
+ traceId,
110
+ spanId
111
+ };
112
+ operationStore.enterWith(context);
113
+ return scope;
114
+ }
115
+ /**
116
+ * Get the current operation context
117
+ */
118
+ function getCurrentOperation() {
119
+ return operationStore.getStore() || null;
120
+ }
121
+ /**
122
+ * Create a new thread context
123
+ */
124
+ function newThread(init) {
125
+ const threadId = init?.threadId || (0, nanoid_1.nanoid)(12);
126
+ const eventId = (0, nanoid_1.nanoid)(12);
127
+ const sequenceNo = init?.sequenceNo || 0;
128
+ const context = {
129
+ threadId,
130
+ eventId,
131
+ causationId: init?.causationId,
132
+ sequenceNo,
133
+ partitionKey: init?.partitionKey,
134
+ attempt: init?.attempt,
135
+ shardId: init?.shardId,
136
+ workerId: init?.workerId
137
+ };
138
+ threadStore.enterWith(context);
139
+ return context;
140
+ }
141
+ /**
142
+ * Continue an existing thread context
143
+ */
144
+ function continueThread(ctx) {
145
+ const currentThread = getCurrentThread();
146
+ const threadId = ctx.threadId || currentThread?.threadId || (0, nanoid_1.nanoid)(12);
147
+ const eventId = (0, nanoid_1.nanoid)(12);
148
+ const sequenceNo = ctx.sequenceNo ?? (currentThread?.sequenceNo ?? 0);
149
+ const context = {
150
+ threadId,
151
+ eventId,
152
+ causationId: ctx.causationId || currentThread?.causationId,
153
+ sequenceNo,
154
+ partitionKey: ctx.partitionKey || currentThread?.partitionKey,
155
+ attempt: ctx.attempt || currentThread?.attempt,
156
+ shardId: ctx.shardId || currentThread?.shardId,
157
+ workerId: ctx.workerId || currentThread?.workerId
158
+ };
159
+ threadStore.enterWith(context);
160
+ return context;
161
+ }
162
+ /**
163
+ * Generate the next event ID and increment sequence
164
+ */
165
+ function nextEventId() {
166
+ const currentThread = getCurrentThread();
167
+ if (!currentThread) {
168
+ throw new Error('No thread context available. Call newThread() or continueThread() first.');
169
+ }
170
+ const eventId = `evt_${(0, nanoid_1.nanoid)(12)}`;
171
+ const newSequenceNo = currentThread.sequenceNo + 1;
172
+ // Update the current thread context with new event and sequence
173
+ const updatedContext = {
174
+ ...currentThread,
175
+ eventId,
176
+ sequenceNo: newSequenceNo,
177
+ causationId: currentThread.eventId
178
+ ? [...(Array.isArray(currentThread.causationId) ? currentThread.causationId : (currentThread.causationId ? [currentThread.causationId] : [])), currentThread.eventId]
179
+ : currentThread.causationId
180
+ };
181
+ threadStore.enterWith(updatedContext);
182
+ return eventId;
183
+ }
184
+ /**
185
+ * Get the current thread context
186
+ */
187
+ function getCurrentThread() {
188
+ return threadStore.getStore() || null;
189
+ }
190
+ /**
191
+ * Clear all contexts (for testing)
192
+ */
193
+ function clearAllContexts() {
194
+ operationStore.enterWith(null);
195
+ threadStore.enterWith(null);
196
+ }
197
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/trails/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA2EH,wCAsCC;AAKD,wCAuCC;AAKD,kDAEC;AAKD,8BAkBC;AAKD,wCAmBC;AAKD,kCAqBC;AAKD,4CAEC;AAKD,4CAGC;AA1PD,6CAAgD;AAChD,mCAAgC;AAGhC,oDAAoD;AACpD,MAAM,cAAc,GAAG,IAAI,+BAAiB,EAAgB,CAAC;AAC7D,MAAM,WAAW,GAAG,IAAI,+BAAiB,EAAiB,CAAC;AAE3D;;GAEG;AACH,MAAa,cAAc;IAUzB,YACE,WAAmB,EACnB,iBAAqC,EACrC,aAAqB,EACrB,aAAqB,EACrB,aAAqB,EACrB,OAAe,EACf,MAAc;QATR,UAAK,GAAG,KAAK,CAAC;QAWpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,IAAI,SAAS,CAAC;QACxD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,G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AAQ,EAAE,IAAI,IAAI,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,cAAc,CAAC,SAAS,CAAC,IAAW,CAAC,CAAC;IACtC,WAAW,CAAC,SAAS,CAAC,IAAW,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,411 @@
1
+ /**
2
+ * logxer - TypeScript Type Definitions
3
+ *
4
+ * This file contains all TypeScript interfaces and types for the logxer package.
5
+ */
6
+ /**
7
+ * Supported log levels in order of priority
8
+ */
9
+ export type LogLevel = 'verbose' | 'debug' | 'info' | 'warn' | 'error';
10
+ /**
11
+ * Output format options for log entries
12
+ */
13
+ export type LogFormat = 'text' | 'json' | 'yaml' | 'table';
14
+ /**
15
+ * Configuration for PII/credentials sanitization
16
+ */
17
+ export interface SanitizationConfig {
18
+ /** Enable sanitization (default: false) */
19
+ enabled?: boolean;
20
+ /** Detector toggles (all default true when enabled) */
21
+ detectEmails?: boolean;
22
+ detectIPs?: boolean;
23
+ detectPhoneNumbers?: boolean;
24
+ detectJWTs?: boolean;
25
+ detectAPIKeys?: boolean;
26
+ detectAWSCreds?: boolean;
27
+ detectAzureKeys?: boolean;
28
+ detectGCPKeys?: boolean;
29
+ detectPasswords?: boolean;
30
+ detectCreditCards?: boolean;
31
+ /** Behavior settings */
32
+ maskWith?: string;
33
+ partialMaskRatio?: number;
34
+ maxDepth?: number;
35
+ keysDenylist?: string[];
36
+ keysAllowlist?: string[];
37
+ fieldsHashInsteadOfMask?: string[];
38
+ }
39
+ /**
40
+ * Configuration for logging behavior
41
+ */
42
+ export interface LoggingConfig {
43
+ /** Enable console output (default: true) */
44
+ logToConsole?: boolean;
45
+ /** Enable file output (default: false) */
46
+ logToFile?: boolean;
47
+ /** File path for logs (required if logToFile is true) */
48
+ logFilePath?: string;
49
+ /** Minimum log level to output (default: 'info') */
50
+ logLevel?: LogLevel;
51
+ /** Output format: 'text' or 'json' (default: 'text') */
52
+ logFormat?: LogFormat;
53
+ /** Show full ISO timestamp in console logs (default: false) */
54
+ showFullTimestamp?: boolean;
55
+ /** Console package filtering: only show logs from these packages (comma-separated, console only) */
56
+ consolePackagesShow?: string[];
57
+ /** Console package filtering: hide logs from these packages (comma-separated, console only) */
58
+ consolePackagesHide?: string[];
59
+ /** Custom logxer implementation (advanced use) */
60
+ customLogger?: CustomLogxer;
61
+ /** Enable unified-logger output (default: false) */
62
+ enableUnifiedLogger?: boolean;
63
+ /** Unified logger configuration */
64
+ unifiedLogger?: UnifiedLoggerConfig;
65
+ /** Default source for logs emitted by this logger if not provided per-call */
66
+ defaultSource?: string;
67
+ /** PII/credentials sanitization configuration */
68
+ sanitization?: SanitizationConfig;
69
+ /** Transport configuration */
70
+ transports?: TransportsConfig;
71
+ /** Tracing configuration */
72
+ tracing?: TracingConfig;
73
+ /** Trails configuration */
74
+ trails?: TrailsConfig;
75
+ /** Schema validation configuration */
76
+ schemaCheck?: {
77
+ enabled?: boolean;
78
+ };
79
+ /** Shadow logging configuration */
80
+ shadow?: ShadowConfig;
81
+ /** Debug scoping configuration (from logxer-debug.json) */
82
+ debugScoping?: DebugScopingConfig;
83
+ }
84
+ /**
85
+ * Between rule for stateful range-based filtering
86
+ */
87
+ export interface BetweenRule {
88
+ /** Action to take when range is active */
89
+ action: 'include' | 'exclude';
90
+ /** If true: exact match (case sensitive), if false: partial match (case insensitive). Default: false */
91
+ exactMatch?: boolean;
92
+ /** If true: search entire log (message, identity, all meta fields), if false: only identity. Default: false */
93
+ searchLog?: boolean;
94
+ /** Identity patterns that start the range. Empty array means range starts from beginning. */
95
+ startIdentities: string[];
96
+ /** Identity patterns that end the range. Empty array means range never ends. */
97
+ endIdentities: string[];
98
+ }
99
+ /**
100
+ * Debug scoping configuration loaded from logxer-debug.json
101
+ */
102
+ export interface DebugScopingConfig {
103
+ scoping: {
104
+ /** Enable or disable runtime filtering */
105
+ status: 'enabled' | 'disabled';
106
+ /** Filter logs by identity (file:function format) */
107
+ filterIdentities?: string[];
108
+ /** Filter logs by application name */
109
+ filteredApplications?: string[];
110
+ /** Stateful range-based filtering rules */
111
+ between?: BetweenRule[];
112
+ };
113
+ }
114
+ /**
115
+ * Custom logxer interface for injecting external logxers (Winston, Pino, etc.)
116
+ */
117
+ export interface CustomLogxer {
118
+ verbose: (message: string, data?: any) => void;
119
+ debug: (message: string, data?: any) => void;
120
+ info: (message: string, data?: any) => void;
121
+ warn: (message: string, data?: any) => void;
122
+ error: (message: string, data?: any) => void;
123
+ success: (message: string, data?: any) => void;
124
+ }
125
+ /**
126
+ * Package identification configuration
127
+ */
128
+ export interface LogxerPackageConfig {
129
+ /** Display name in logs (e.g., 'MY_APP', 'DATABASE_SERVICE') */
130
+ packageName: string;
131
+ /** Environment variable prefix (e.g., 'MY_APP', 'DB_SERVICE') */
132
+ envPrefix: string;
133
+ /** Debug namespace for DEBUG env var (e.g., 'my-app', 'db-service') */
134
+ debugNamespace?: string;
135
+ }
136
+ /**
137
+ * Structured log entry (used for JSON format)
138
+ */
139
+ export interface LogEntry {
140
+ timestamp: string;
141
+ package: string;
142
+ level: string;
143
+ message: string;
144
+ data?: any;
145
+ /** Consuming application name (auto-detected from package.json) */
146
+ appName?: string;
147
+ /** Consuming application version (auto-detected from package.json) */
148
+ appVersion?: string;
149
+ }
150
+ /**
151
+ * Routing metadata for controlling log output destinations
152
+ */
153
+ export interface RoutingMeta {
154
+ /** Allowed output destinations (e.g., ['unified-logger', 'console']) */
155
+ allowedOutputs?: string[];
156
+ /** Blocked output destinations (e.g., ['unified-logger', 'file']) */
157
+ blockOutputs?: string[];
158
+ /** Debugging aid for why routing rules were applied */
159
+ reason?: string;
160
+ /** Optional hints for routing decisions */
161
+ tags?: string[];
162
+ }
163
+ /**
164
+ * Log metadata that can be attached to log entries
165
+ */
166
+ export interface LogMeta {
167
+ /** Backward-compatible payload - any additional data */
168
+ [key: string]: any;
169
+ /** Source identifier for the log entry */
170
+ source?: string;
171
+ /** Identity identifier for the log entry (unique based on code location, auto-generated if not provided) */
172
+ identity?: string;
173
+ /** Correlation ID for tracing related log entries */
174
+ correlationId?: string;
175
+ /** Routing metadata for controlling output destinations */
176
+ _routing?: RoutingMeta;
177
+ /** Shadow logging override metadata */
178
+ _shadow?: {
179
+ /** Override runId for shadow capture */
180
+ runId?: string;
181
+ };
182
+ }
183
+ /**
184
+ * Unified logger transport configuration
185
+ */
186
+ export interface UnifiedLoggerTransports {
187
+ /** Enable console output via unified-logger */
188
+ console?: boolean;
189
+ /** Enable Papertrail output via unified-logger */
190
+ papertrail?: boolean;
191
+ /** Enable UDP relay output via unified-logger */
192
+ udpRelay?: boolean;
193
+ }
194
+ /**
195
+ * Unified logger configuration
196
+ */
197
+ export interface UnifiedLoggerConfig {
198
+ /** Path to logger.json config file */
199
+ configPath?: string;
200
+ /** Inline @x-developer/unified-logger ILoggerConfig */
201
+ configInline?: any;
202
+ /** Simple overrides */
203
+ service?: string;
204
+ env?: string;
205
+ level?: 'verbose' | 'debug' | 'info' | 'warn' | 'error';
206
+ transports?: UnifiedLoggerTransports;
207
+ /** Optional level filter for this output */
208
+ levels?: LogLevel[];
209
+ }
210
+ /**
211
+ * Internal configuration type with all required fields
212
+ */
213
+ export type InternalLoggingConfig = Required<Omit<LoggingConfig, 'customLogger' | 'unifiedLogger' | 'transports' | 'tracing' | 'trails' | 'schemaCheck' | 'shadow' | 'consolePackagesShow' | 'consolePackagesHide' | 'debugScoping'>> & {
214
+ customLogger?: CustomLogxer;
215
+ unifiedLogger?: UnifiedLoggerConfig;
216
+ /** When true, package diagnostics are suppressed regardless of DEBUG or sinks (see resolvePackageLogsLevel). */
217
+ packageLogsDisabled: boolean;
218
+ packageName: string;
219
+ transports?: TransportsConfig;
220
+ tracing?: TracingConfig;
221
+ trails?: TrailsConfig;
222
+ schemaCheck?: {
223
+ enabled?: boolean;
224
+ };
225
+ shadow?: ShadowConfig;
226
+ consolePackagesShow?: string[] | undefined;
227
+ consolePackagesHide?: string[] | undefined;
228
+ debugScoping?: DebugScopingConfig;
229
+ };
230
+ /**
231
+ * Trails configuration for operation and thread tracking
232
+ */
233
+ export interface TrailsConfig {
234
+ /** Enable depth/operation trail tracking */
235
+ enableDepthTrail?: boolean;
236
+ /** Enable thread/causal trail tracking */
237
+ enableThreadTrail?: boolean;
238
+ /** Inject trail headers on outbound requests */
239
+ injectHeaders?: boolean;
240
+ /** Extract trail headers from inbound requests */
241
+ extractHeaders?: boolean;
242
+ /** Maximum sequence number window for thread tracking */
243
+ sequenceWindow?: number;
244
+ }
245
+ /**
246
+ * Shadow logging configuration for per-run debug capture
247
+ */
248
+ export interface ShadowConfig {
249
+ /** Enable shadow logging (default: false) */
250
+ enabled?: boolean;
251
+ /** Output format for shadow files (default: 'json') */
252
+ format?: 'json' | 'yaml';
253
+ /** Directory for shadow files (default: './logs/shadow') */
254
+ directory?: string;
255
+ /** Time-to-live in milliseconds (default: 86400000 = 1 day) */
256
+ ttlMs?: number;
257
+ /** Respect routing blockOutputs metadata (default: true) */
258
+ respectRoutingBlocks?: boolean;
259
+ /** Rolling buffer for after-the-fact capture */
260
+ rollingBuffer?: {
261
+ /** Maximum number of entries to buffer (default: 0 = disabled) */
262
+ maxEntries?: number;
263
+ /** Maximum age of buffered entries in ms (default: 0 = disabled) */
264
+ maxAgeMs?: number;
265
+ };
266
+ }
267
+ /**
268
+ * Shadow controller interface for runtime management
269
+ */
270
+ export interface ShadowController {
271
+ /** Enable shadow capture for a specific runId */
272
+ enable(runId: string, opts?: Partial<ShadowConfig>): void;
273
+ /** Disable shadow capture for a specific runId */
274
+ disable(runId: string): void;
275
+ /** Check if shadow capture is enabled for a runId */
276
+ isEnabled(runId: string): boolean;
277
+ /** List all active shadow captures */
278
+ listActive(): {
279
+ runId: string;
280
+ since: string;
281
+ format: 'json' | 'yaml';
282
+ }[];
283
+ /** Export shadow file to a destination path */
284
+ export(runId: string, outPath?: string): Promise<string>;
285
+ /** Clean up expired shadow files based on TTL */
286
+ cleanupExpired(now?: number): Promise<number>;
287
+ }
288
+ /**
289
+ * Transport configuration options
290
+ */
291
+ export interface TransportsConfig {
292
+ /** Core logging transport: pino (high-perf) or builtin (fallback) */
293
+ core?: 'pino' | 'builtin';
294
+ /** File rotation strategy: winston (daily), rfs (size/interval), or none */
295
+ fileRotation?: 'winston' | 'rfs' | 'none';
296
+ /** Enable pretty output in development */
297
+ devPretty?: boolean;
298
+ }
299
+ /**
300
+ * Tracing configuration for OpenTelemetry integration
301
+ */
302
+ export interface TracingConfig {
303
+ /** Enable OpenTelemetry context integration (no-op if @opentelemetry/api not available) */
304
+ enableOtelContext?: boolean;
305
+ }
306
+ /**
307
+ * Operation context for depth trail tracking
308
+ */
309
+ export interface OperationCtx {
310
+ /** Unique operation identifier */
311
+ operationId: string;
312
+ /** Parent operation identifier */
313
+ parentOperationId?: string | undefined;
314
+ /** Human-readable operation name */
315
+ operationName: string;
316
+ /** Hierarchical operation path */
317
+ operationPath: string;
318
+ /** Step number within operation */
319
+ operationStep: number;
320
+ /** Trace identifier */
321
+ traceId: string;
322
+ /** Span identifier */
323
+ spanId: string;
324
+ }
325
+ /**
326
+ * Thread context for causal trail tracking
327
+ */
328
+ export interface ThreadContext {
329
+ /** Unique thread identifier */
330
+ threadId: string;
331
+ /** Current event identifier */
332
+ eventId: string;
333
+ /** Causation chain (events that caused this one) */
334
+ causationId?: string | string[] | undefined;
335
+ /** Sequence number within thread */
336
+ sequenceNo: number;
337
+ /** Partition key for distributed processing */
338
+ partitionKey?: string | undefined;
339
+ /** Retry attempt number */
340
+ attempt?: number | undefined;
341
+ /** Shard identifier */
342
+ shardId?: string | undefined;
343
+ /** Worker identifier */
344
+ workerId?: string | undefined;
345
+ }
346
+ /**
347
+ * Normalized log envelope structure
348
+ */
349
+ export interface LogEnvelope {
350
+ /** ISO timestamp */
351
+ timestamp: string;
352
+ /** Package name */
353
+ package: string;
354
+ /** Log level */
355
+ level: string;
356
+ /** Log message */
357
+ message: string;
358
+ /** Source identifier */
359
+ source: string;
360
+ /** Sanitized payload data */
361
+ data?: any;
362
+ /** Consuming application name (auto-detected from package.json) */
363
+ appName?: string;
364
+ /** Consuming application version (auto-detected from package.json) */
365
+ appVersion?: string;
366
+ /** Correlation identifier */
367
+ correlationId?: string;
368
+ /** Job identifier */
369
+ jobId?: string;
370
+ /** Run identifier */
371
+ runId?: string;
372
+ /** Session identifier */
373
+ sessionId?: string;
374
+ /** Operation identifier */
375
+ operationId?: string;
376
+ /** Parent operation identifier */
377
+ parentOperationId?: string;
378
+ /** Operation name */
379
+ operationName?: string;
380
+ /** Operation path */
381
+ operationPath?: string;
382
+ /** Operation step */
383
+ operationStep?: number;
384
+ /** Thread identifier */
385
+ threadId?: string;
386
+ /** Event identifier */
387
+ eventId?: string;
388
+ /** Causation identifier(s) */
389
+ causationId?: string | string[];
390
+ /** Sequence number */
391
+ sequenceNo?: number;
392
+ /** Partition key */
393
+ partitionKey?: string;
394
+ /** Attempt number */
395
+ attempt?: number;
396
+ /** Shard identifier */
397
+ shardId?: string;
398
+ /** Worker identifier */
399
+ workerId?: string;
400
+ /** Trace identifier */
401
+ traceId?: string;
402
+ /** Span identifier */
403
+ spanId?: string;
404
+ /** Identity identifier for the log entry (unique based on code location) */
405
+ identity?: string;
406
+ /** Routing metadata */
407
+ _routing?: RoutingMeta;
408
+ /** Free-form tags */
409
+ tags?: string[];
410
+ }
411
+ //# sourceMappingURL=types.d.ts.map