xcally-nest-library 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,33 +1,44 @@
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
2
2
|
import { PinoLogger } from 'nestjs-pino';
|
3
3
|
import api from '@opentelemetry/api';
|
4
|
-
|
4
|
+
/**
|
5
|
+
* @interface LoggerMeta
|
6
|
+
* @description Interface representing metadata for logging purposes.
|
7
|
+
*
|
8
|
+
* @property {any} [payload] - Optional payload data to be logged.
|
9
|
+
*
|
10
|
+
* @property {any} [ctx] - Optional context information to be logged. Used for audit logging.
|
11
|
+
*/
|
12
|
+
interface LoggerMeta {
|
13
|
+
payload?: any;
|
14
|
+
ctx?: any;
|
15
|
+
}
|
5
16
|
@Injectable()
|
6
17
|
export class LoggerService {
|
7
18
|
constructor(private readonly logger: PinoLogger) {}
|
8
19
|
|
9
|
-
debug(msg: string, meta?:
|
20
|
+
debug(msg: string, meta?: LoggerMeta): void {
|
10
21
|
const activeSpan = api.trace.getSpan(api.context.active());
|
11
22
|
activeSpan.addEvent(msg);
|
12
23
|
this.logger.debug({ meta }, msg);
|
13
24
|
}
|
14
|
-
warn(msg: string, meta?:
|
25
|
+
warn(msg: string, meta?: LoggerMeta): void {
|
15
26
|
const activeSpan = api.trace.getSpan(api.context.active());
|
16
27
|
activeSpan.addEvent(msg);
|
17
28
|
this.logger.warn({ meta }, msg);
|
18
29
|
}
|
19
|
-
error(msg: string, meta?:
|
30
|
+
error(msg: string, meta?: LoggerMeta): void {
|
20
31
|
const activeSpan = api.trace.getSpan(api.context.active());
|
21
32
|
activeSpan.addEvent(msg);
|
22
33
|
this.logger.error({ meta }, msg);
|
23
34
|
}
|
24
|
-
fatal(msg: string, meta?:
|
35
|
+
fatal(msg: string, meta?: LoggerMeta): void {
|
25
36
|
const activeSpan = api.trace.getSpan(api.context.active());
|
26
37
|
activeSpan.addEvent(msg);
|
27
38
|
this.logger.fatal({ meta }, msg);
|
28
39
|
}
|
29
40
|
|
30
|
-
info(msg: string, meta?:
|
41
|
+
info(msg: string, meta?: LoggerMeta): void {
|
31
42
|
// LOG EVENTS
|
32
43
|
const activeSpan = api.trace.getSpan(api.context.active());
|
33
44
|
activeSpan.addEvent(msg);
|
@@ -42,7 +53,7 @@ export class LoggerService {
|
|
42
53
|
this.logger.info({ meta }, msg);
|
43
54
|
}
|
44
55
|
|
45
|
-
trace(msg: string, meta?:
|
56
|
+
trace(msg: string, meta?: LoggerMeta): void {
|
46
57
|
const activeSpan = api.trace.getSpan(api.context.active());
|
47
58
|
activeSpan.addEvent(msg);
|
48
59
|
this.logger.trace({ meta }, msg);
|