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