@dex-monit/observability-sdk-node 1.0.6 → 1.0.7
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/dist/lib/dex-logger.service.d.ts +88 -0
- package/dist/lib/dex-logger.service.d.ts.map +1 -0
- package/dist/lib/dex-logger.service.js +172 -0
- package/dist/lib/sdk-node.d.ts +2 -0
- package/dist/lib/sdk-node.d.ts.map +1 -1
- package/dist/lib/sdk-node.js +2 -0
- package/dist/lib/sdk-node.module.d.ts +1 -1
- package/dist/lib/sdk-node.module.d.ts.map +1 -1
- package/dist/lib/sdk-node.module.js +35 -12
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { LoggerService } from '@nestjs/common';
|
|
2
|
+
import { MonitoringClient } from './monitoring-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Token for injecting DexLoggerService
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEX_LOGGER_TOKEN = "DEX_LOGGER_SERVICE";
|
|
7
|
+
/**
|
|
8
|
+
* DexLoggerService - NestJS compatible logger that sends logs to monitoring
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* 1. Inject in any service/controller: constructor(private logger: DexLoggerService)
|
|
12
|
+
* 2. Use as app logger: app.useLogger(app.get(DexLoggerService))
|
|
13
|
+
*
|
|
14
|
+
* Example:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @Injectable()
|
|
17
|
+
* export class MyService {
|
|
18
|
+
* constructor(private readonly logger: DexLoggerService) {
|
|
19
|
+
* this.logger.setContext('MyService');
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* doSomething() {
|
|
23
|
+
* this.logger.log('Doing something');
|
|
24
|
+
* this.logger.warn('This is a warning');
|
|
25
|
+
* this.logger.error('This is an error');
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class DexLoggerService implements LoggerService {
|
|
31
|
+
private context?;
|
|
32
|
+
private monitoringClient?;
|
|
33
|
+
/**
|
|
34
|
+
* Set the monitoring client (called by module)
|
|
35
|
+
*/
|
|
36
|
+
setMonitoringClient(client?: MonitoringClient): void;
|
|
37
|
+
/**
|
|
38
|
+
* Set the context (usually the class name)
|
|
39
|
+
*/
|
|
40
|
+
setContext(context: string): this;
|
|
41
|
+
/**
|
|
42
|
+
* Log a message (info level)
|
|
43
|
+
*/
|
|
44
|
+
log(message: string, context?: string): void;
|
|
45
|
+
log(message: string, ...optionalParams: unknown[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Log an error message
|
|
48
|
+
*/
|
|
49
|
+
error(message: string, stackOrContext?: string): void;
|
|
50
|
+
error(message: string, stack?: string, context?: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Log a warning message
|
|
53
|
+
*/
|
|
54
|
+
warn(message: string, context?: string): void;
|
|
55
|
+
warn(message: string, ...optionalParams: unknown[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Log a debug message
|
|
58
|
+
*/
|
|
59
|
+
debug(message: string, context?: string): void;
|
|
60
|
+
debug(message: string, ...optionalParams: unknown[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* Log a verbose message (maps to debug)
|
|
63
|
+
*/
|
|
64
|
+
verbose(message: string, context?: string): void;
|
|
65
|
+
verbose(message: string, ...optionalParams: unknown[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Log a fatal message
|
|
68
|
+
*/
|
|
69
|
+
fatal(message: string, context?: string): void;
|
|
70
|
+
fatal(message: string, ...optionalParams: unknown[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Internal: write log to console and send to monitoring
|
|
73
|
+
*/
|
|
74
|
+
private writeLog;
|
|
75
|
+
/**
|
|
76
|
+
* Get the appropriate console method for the log level
|
|
77
|
+
*/
|
|
78
|
+
private getConsoleMethod;
|
|
79
|
+
/**
|
|
80
|
+
* Extract context from optional params
|
|
81
|
+
*/
|
|
82
|
+
private extractContext;
|
|
83
|
+
/**
|
|
84
|
+
* Extract context and stack from error params
|
|
85
|
+
*/
|
|
86
|
+
private extractErrorParams;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=dex-logger.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dex-logger.service.d.ts","sourceRoot":"","sources":["../../src/lib/dex-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAS,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D;;GAEG;AACH,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAE5C;;OAEG;IACH,mBAAmB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAIpD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjC;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC5C,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAMxD;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IACrD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAM9D;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAMzD;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC9C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAM1D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAChD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAM5D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC9C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAM1D;;OAEG;IACH,OAAO,CAAC,QAAQ;IAsChB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAQtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CA4B3B"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { Injectable, Scope } from '@nestjs/common';
|
|
3
|
+
import { RequestContextService } from '@dex-monit/observability-request-context';
|
|
4
|
+
/**
|
|
5
|
+
* Token for injecting DexLoggerService
|
|
6
|
+
*/
|
|
7
|
+
export const DEX_LOGGER_TOKEN = 'DEX_LOGGER_SERVICE';
|
|
8
|
+
/**
|
|
9
|
+
* DexLoggerService - NestJS compatible logger that sends logs to monitoring
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* 1. Inject in any service/controller: constructor(private logger: DexLoggerService)
|
|
13
|
+
* 2. Use as app logger: app.useLogger(app.get(DexLoggerService))
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* @Injectable()
|
|
18
|
+
* export class MyService {
|
|
19
|
+
* constructor(private readonly logger: DexLoggerService) {
|
|
20
|
+
* this.logger.setContext('MyService');
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* doSomething() {
|
|
24
|
+
* this.logger.log('Doing something');
|
|
25
|
+
* this.logger.warn('This is a warning');
|
|
26
|
+
* this.logger.error('This is an error');
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
let DexLoggerService = (() => {
|
|
32
|
+
let _classDecorators = [Injectable({ scope: Scope.TRANSIENT })];
|
|
33
|
+
let _classDescriptor;
|
|
34
|
+
let _classExtraInitializers = [];
|
|
35
|
+
let _classThis;
|
|
36
|
+
var DexLoggerService = class {
|
|
37
|
+
static { _classThis = this; }
|
|
38
|
+
static {
|
|
39
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
40
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
41
|
+
DexLoggerService = _classThis = _classDescriptor.value;
|
|
42
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
43
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
44
|
+
}
|
|
45
|
+
context;
|
|
46
|
+
monitoringClient;
|
|
47
|
+
/**
|
|
48
|
+
* Set the monitoring client (called by module)
|
|
49
|
+
*/
|
|
50
|
+
setMonitoringClient(client) {
|
|
51
|
+
this.monitoringClient = client;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set the context (usually the class name)
|
|
55
|
+
*/
|
|
56
|
+
setContext(context) {
|
|
57
|
+
this.context = context;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
log(message, ...optionalParams) {
|
|
61
|
+
const ctx = this.extractContext(optionalParams);
|
|
62
|
+
this.writeLog('info', message, ctx);
|
|
63
|
+
}
|
|
64
|
+
error(message, ...optionalParams) {
|
|
65
|
+
const { context, stack } = this.extractErrorParams(optionalParams);
|
|
66
|
+
this.writeLog('error', message, context, { stack });
|
|
67
|
+
}
|
|
68
|
+
warn(message, ...optionalParams) {
|
|
69
|
+
const ctx = this.extractContext(optionalParams);
|
|
70
|
+
this.writeLog('warning', message, ctx);
|
|
71
|
+
}
|
|
72
|
+
debug(message, ...optionalParams) {
|
|
73
|
+
const ctx = this.extractContext(optionalParams);
|
|
74
|
+
this.writeLog('debug', message, ctx);
|
|
75
|
+
}
|
|
76
|
+
verbose(message, ...optionalParams) {
|
|
77
|
+
const ctx = this.extractContext(optionalParams);
|
|
78
|
+
this.writeLog('debug', message, ctx);
|
|
79
|
+
}
|
|
80
|
+
fatal(message, ...optionalParams) {
|
|
81
|
+
const ctx = this.extractContext(optionalParams);
|
|
82
|
+
this.writeLog('fatal', message, ctx);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Internal: write log to console and send to monitoring
|
|
86
|
+
*/
|
|
87
|
+
writeLog(level, message, context, extra) {
|
|
88
|
+
const ctx = context || this.context || 'Application';
|
|
89
|
+
const requestContext = RequestContextService.get();
|
|
90
|
+
const timestamp = new Date().toISOString();
|
|
91
|
+
// Format for console output
|
|
92
|
+
const logData = {
|
|
93
|
+
timestamp,
|
|
94
|
+
level: level.toUpperCase(),
|
|
95
|
+
context: ctx,
|
|
96
|
+
message,
|
|
97
|
+
requestId: requestContext?.requestId,
|
|
98
|
+
transactionId: requestContext?.transactionId,
|
|
99
|
+
...extra,
|
|
100
|
+
};
|
|
101
|
+
// Write to console (JSON format)
|
|
102
|
+
const consoleMethod = this.getConsoleMethod(level);
|
|
103
|
+
consoleMethod(JSON.stringify(logData));
|
|
104
|
+
// Send to monitoring (fire and forget)
|
|
105
|
+
if (this.monitoringClient) {
|
|
106
|
+
this.monitoringClient.captureLog(level, message, {
|
|
107
|
+
context: ctx,
|
|
108
|
+
requestId: requestContext?.requestId,
|
|
109
|
+
transactionId: requestContext?.transactionId,
|
|
110
|
+
...extra,
|
|
111
|
+
}).catch(() => {
|
|
112
|
+
// Silently fail
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get the appropriate console method for the log level
|
|
118
|
+
*/
|
|
119
|
+
getConsoleMethod(level) {
|
|
120
|
+
switch (level) {
|
|
121
|
+
case 'debug':
|
|
122
|
+
return console.debug.bind(console);
|
|
123
|
+
case 'info':
|
|
124
|
+
return console.log.bind(console);
|
|
125
|
+
case 'warning':
|
|
126
|
+
return console.warn.bind(console);
|
|
127
|
+
case 'error':
|
|
128
|
+
case 'fatal':
|
|
129
|
+
return console.error.bind(console);
|
|
130
|
+
default:
|
|
131
|
+
return console.log.bind(console);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Extract context from optional params
|
|
136
|
+
*/
|
|
137
|
+
extractContext(optionalParams) {
|
|
138
|
+
const lastParam = optionalParams[optionalParams.length - 1];
|
|
139
|
+
if (typeof lastParam === 'string') {
|
|
140
|
+
return lastParam;
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Extract context and stack from error params
|
|
146
|
+
*/
|
|
147
|
+
extractErrorParams(optionalParams) {
|
|
148
|
+
if (optionalParams.length === 0) {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
if (optionalParams.length === 1) {
|
|
152
|
+
const param = optionalParams[0];
|
|
153
|
+
if (typeof param === 'string') {
|
|
154
|
+
// Could be stack or context - check if it looks like a stack
|
|
155
|
+
if (param.includes('\n') && param.includes('at ')) {
|
|
156
|
+
return { stack: param };
|
|
157
|
+
}
|
|
158
|
+
return { context: param };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (optionalParams.length >= 2) {
|
|
162
|
+
return {
|
|
163
|
+
stack: typeof optionalParams[0] === 'string' ? optionalParams[0] : undefined,
|
|
164
|
+
context: typeof optionalParams[1] === 'string' ? optionalParams[1] : undefined,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
return DexLoggerService = _classThis;
|
|
171
|
+
})();
|
|
172
|
+
export { DexLoggerService };
|
package/dist/lib/sdk-node.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export * from './request-id.middleware.js';
|
|
|
3
3
|
export * from './global-exception.filter.js';
|
|
4
4
|
export * from './error-capture.interceptor.js';
|
|
5
5
|
export * from './monitoring-client.js';
|
|
6
|
+
export * from './remote-logger.js';
|
|
7
|
+
export * from './dex-logger.service.js';
|
|
6
8
|
export * from './console-capture.js';
|
|
7
9
|
//# sourceMappingURL=sdk-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-node.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-node.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"sdk-node.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-node.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
package/dist/lib/sdk-node.js
CHANGED
|
@@ -4,4 +4,6 @@ export * from './request-id.middleware.js';
|
|
|
4
4
|
export * from './global-exception.filter.js';
|
|
5
5
|
export * from './error-capture.interceptor.js';
|
|
6
6
|
export * from './monitoring-client.js';
|
|
7
|
+
export * from './remote-logger.js';
|
|
8
|
+
export * from './dex-logger.service.js';
|
|
7
9
|
export * from './console-capture.js';
|
|
@@ -29,7 +29,7 @@ export declare const MONITORING_CLIENT_TOKEN = "OBSERVABILITY_MONITORING_CLIENT"
|
|
|
29
29
|
* - Request ID middleware for tracing
|
|
30
30
|
* - Error capture interceptor (captures ALL errors, even if other filters exist)
|
|
31
31
|
* - Global exception filter for error capture
|
|
32
|
-
* -
|
|
32
|
+
* - DexLoggerService (NestJS compatible logger with remote capture)
|
|
33
33
|
* - Console capture (intercepts console.log/warn/error)
|
|
34
34
|
* - Monitoring client instance
|
|
35
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-node.module.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-node.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,kBAAkB,EAClB,UAAU,EACV,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAEL,sBAAsB,EAEvB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-node.module.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-node.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,kBAAkB,EAClB,UAAU,EACV,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAEL,sBAAsB,EAEvB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAEL,YAAY,EACZ,YAAY,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,yFAAyF;IACzF,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,2CAA2C;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,gEAAgE;IAChE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAGD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,uBAAuB,oCAAoC,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,qBAEa,aAAc,YAAW,UAAU,EAAE,eAAe;IAC/D,OAAO,CAAC,MAAM,CAAC,YAAY,CAA6B;IAExD;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa;IAwF1D;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAK7C;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CASvC"}
|
|
@@ -6,6 +6,7 @@ import { GlobalExceptionFilter } from './global-exception.filter.js';
|
|
|
6
6
|
import { ErrorCaptureInterceptor } from './error-capture.interceptor.js';
|
|
7
7
|
import { MonitoringClient, createMonitoringClient, } from './monitoring-client.js';
|
|
8
8
|
import { RemoteLogger, createRemoteLogger } from './remote-logger.js';
|
|
9
|
+
import { DexLoggerService, DEX_LOGGER_TOKEN } from './dex-logger.service.js';
|
|
9
10
|
import { startConsoleCapture, stopConsoleCapture } from './console-capture.js';
|
|
10
11
|
import { Logger, LOGGER_TOKEN, } from '@dex-monit/observability-logger';
|
|
11
12
|
// Re-export LOGGER_TOKEN for convenience
|
|
@@ -21,7 +22,7 @@ export const MONITORING_CLIENT_TOKEN = 'OBSERVABILITY_MONITORING_CLIENT';
|
|
|
21
22
|
* - Request ID middleware for tracing
|
|
22
23
|
* - Error capture interceptor (captures ALL errors, even if other filters exist)
|
|
23
24
|
* - Global exception filter for error capture
|
|
24
|
-
* -
|
|
25
|
+
* - DexLoggerService (NestJS compatible logger with remote capture)
|
|
25
26
|
* - Console capture (intercepts console.log/warn/error)
|
|
26
27
|
* - Monitoring client instance
|
|
27
28
|
*/
|
|
@@ -61,6 +62,33 @@ let SdkNodeModule = (() => {
|
|
|
61
62
|
return {
|
|
62
63
|
module: SdkNodeModule,
|
|
63
64
|
providers: [
|
|
65
|
+
// Monitoring Client
|
|
66
|
+
{
|
|
67
|
+
provide: MONITORING_CLIENT_TOKEN,
|
|
68
|
+
useValue: monitoringClient,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
provide: MonitoringClient,
|
|
72
|
+
useValue: monitoringClient,
|
|
73
|
+
},
|
|
74
|
+
// DexLoggerService - the main logger to use
|
|
75
|
+
{
|
|
76
|
+
provide: DEX_LOGGER_TOKEN,
|
|
77
|
+
useFactory: () => {
|
|
78
|
+
const dexLogger = new DexLoggerService();
|
|
79
|
+
dexLogger.setMonitoringClient(monitoringClient);
|
|
80
|
+
return dexLogger;
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
provide: DexLoggerService,
|
|
85
|
+
useFactory: () => {
|
|
86
|
+
const dexLogger = new DexLoggerService();
|
|
87
|
+
dexLogger.setMonitoringClient(monitoringClient);
|
|
88
|
+
return dexLogger;
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
// Legacy Logger support
|
|
64
92
|
{
|
|
65
93
|
provide: LOGGER_TOKEN,
|
|
66
94
|
useValue: logger,
|
|
@@ -73,16 +101,7 @@ let SdkNodeModule = (() => {
|
|
|
73
101
|
provide: RemoteLogger,
|
|
74
102
|
useValue: logger,
|
|
75
103
|
},
|
|
76
|
-
{
|
|
77
|
-
provide: MONITORING_CLIENT_TOKEN,
|
|
78
|
-
useValue: monitoringClient,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
provide: MonitoringClient,
|
|
82
|
-
useValue: monitoringClient,
|
|
83
|
-
},
|
|
84
104
|
// Interceptor captures errors BEFORE any exception filter
|
|
85
|
-
// This ensures we capture errors even if another filter handles them
|
|
86
105
|
{
|
|
87
106
|
provide: APP_INTERCEPTOR,
|
|
88
107
|
useFactory: () => new ErrorCaptureInterceptor(monitoringClient),
|
|
@@ -95,11 +114,15 @@ let SdkNodeModule = (() => {
|
|
|
95
114
|
RequestIdMiddleware,
|
|
96
115
|
],
|
|
97
116
|
exports: [
|
|
117
|
+
// Main exports
|
|
118
|
+
DexLoggerService,
|
|
119
|
+
DEX_LOGGER_TOKEN,
|
|
120
|
+
MONITORING_CLIENT_TOKEN,
|
|
121
|
+
MonitoringClient,
|
|
122
|
+
// Legacy exports
|
|
98
123
|
LOGGER_TOKEN,
|
|
99
124
|
Logger,
|
|
100
125
|
RemoteLogger,
|
|
101
|
-
MONITORING_CLIENT_TOKEN,
|
|
102
|
-
MonitoringClient,
|
|
103
126
|
],
|
|
104
127
|
};
|
|
105
128
|
}
|