xcally-nest-library 0.0.33 → 0.0.35
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/src/modules/db-hooks-subscriber/db-hooks-subscriber.module.d.ts +2 -0
- package/dist/src/modules/db-hooks-subscriber/db-hooks-subscriber.module.js +22 -0
- package/dist/src/modules/db-hooks-subscriber/db-hooks-subscriber.module.js.map +1 -0
- package/dist/src/modules/logger/pino/logger.module.d.ts +1 -0
- package/dist/src/modules/logger/pino/logger.module.js +3 -0
- package/dist/src/modules/logger/pino/logger.module.js.map +1 -1
- package/dist/src/modules/logger/pino/logger.service.d.ts +5 -1
- package/dist/src/modules/logger/pino/logger.service.js +25 -8
- package/dist/src/modules/logger/pino/logger.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modules/logger/pino/logger.module.ts +4 -0
- package/src/modules/logger/pino/logger.service.ts +27 -6
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
exports.DbHooksSubscriberModule = void 0;
|
10
|
+
const common_1 = require("@nestjs/common");
|
11
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
12
|
+
let DbHooksSubscriberModule = class DbHooksSubscriberModule {
|
13
|
+
};
|
14
|
+
exports.DbHooksSubscriberModule = DbHooksSubscriberModule;
|
15
|
+
exports.DbHooksSubscriberModule = DbHooksSubscriberModule = __decorate([
|
16
|
+
(0, common_1.Module)({
|
17
|
+
imports: [
|
18
|
+
nestjs_cls_1.ClsModule,
|
19
|
+
],
|
20
|
+
})
|
21
|
+
], DbHooksSubscriberModule);
|
22
|
+
//# sourceMappingURL=db-hooks-subscriber.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"db-hooks-subscriber.module.js","sourceRoot":"","sources":["../../../../src/modules/db-hooks-subscriber/db-hooks-subscriber.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAAuC;AAShC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CAAG,CAAA;AAA1B,0DAAuB;kCAAvB,uBAAuB;IAPnC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAS;SAEV;KAEF,CAAC;GACW,uBAAuB,CAAG"}
|
@@ -7,6 +7,7 @@ export interface LoggerModuleOptions {
|
|
7
7
|
'resource.service.deployment.environment'?: string;
|
8
8
|
'resource.service.deployment.id'?: string;
|
9
9
|
'resource.service.deployment.revision'?: string;
|
10
|
+
autoLogging?: boolean;
|
10
11
|
}
|
11
12
|
export declare class LoggerModule {
|
12
13
|
static forRoot(options: LoggerModuleOptions): DynamicModule;
|
@@ -13,6 +13,7 @@ const config_1 = require("@nestjs/config");
|
|
13
13
|
const nestjs_pino_1 = require("nestjs-pino");
|
14
14
|
const logger_service_1 = require("./logger.service");
|
15
15
|
const constants_1 = require("./constants");
|
16
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
16
17
|
let LoggerModule = LoggerModule_1 = class LoggerModule {
|
17
18
|
static forRoot(options) {
|
18
19
|
const loggerOptions = {
|
@@ -26,6 +27,7 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
26
27
|
providers,
|
27
28
|
exports,
|
28
29
|
imports: [
|
30
|
+
nestjs_cls_1.ClsModule,
|
29
31
|
nestjs_pino_1.LoggerModule.forRootAsync({
|
30
32
|
imports: [config_1.ConfigModule],
|
31
33
|
inject: [config_1.ConfigService],
|
@@ -41,6 +43,7 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
41
43
|
return 'info';
|
42
44
|
},
|
43
45
|
level: config.get('LOG_LEVEL') || 'info',
|
46
|
+
autoLogging: options.autoLogging || true,
|
44
47
|
redact: {
|
45
48
|
paths: ['req.headers.cookie', 'req.headers.authorization'],
|
46
49
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AACjD,2CAA6C;
|
1
|
+
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AACjD,2CAA6C;AAC7C,2CAAuC;AAchC,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB,MAAM,CAAC,OAAO,CAAC,OAA4B;QACzC,MAAM,aAAa,GAAG;YACpB,OAAO,EAAE,0BAAc;YACvB,QAAQ,EAAE,OAAO;SAClB,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,8BAAa,EAAE,aAAa,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,CAAC,8BAAa,EAAE,aAAa,CAAC,CAAC;QAC/C,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,SAAS;YACT,OAAO;YACP,OAAO,EAAE;gBACP,sBAAS;gBACT,0BAAgB,CAAC,YAAY,CAAC;oBAC5B,OAAO,EAAE,CAAC,qBAAY,CAAC;oBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;oBACvB,UAAU,EAAE,KAAK,EAAE,MAAqB,EAAE,EAAE;wBAC1C,MAAM,WAA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,eAAM,GAAE;GACI,YAAY,CAkFxB"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { PinoLogger } from 'nestjs-pino';
|
2
2
|
import { LoggerModuleOptions } from './logger.module';
|
3
|
+
import { ClsService } from 'nestjs-cls';
|
3
4
|
interface LoggerMeta {
|
4
5
|
ctx?: any;
|
5
6
|
[key: string]: any;
|
@@ -7,12 +8,15 @@ interface LoggerMeta {
|
|
7
8
|
export declare class LoggerService {
|
8
9
|
private readonly loggerOptions;
|
9
10
|
private readonly logger;
|
10
|
-
|
11
|
+
private readonly cls;
|
12
|
+
constructor(loggerOptions: LoggerModuleOptions, logger: PinoLogger, cls: ClsService);
|
13
|
+
private withAdditionalTraceId;
|
11
14
|
debug(msg: string, meta?: LoggerMeta): void;
|
12
15
|
warn(msg: string, meta?: LoggerMeta): void;
|
13
16
|
error(msg: string, meta?: LoggerMeta): void;
|
14
17
|
fatal(msg: string, meta?: LoggerMeta): void;
|
15
18
|
info(msg: string, meta?: LoggerMeta): void;
|
16
19
|
trace(msg: string, meta?: LoggerMeta): void;
|
20
|
+
someMethod(): void;
|
17
21
|
}
|
18
22
|
export {};
|
@@ -16,34 +16,51 @@ exports.LoggerService = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
17
17
|
const nestjs_pino_1 = require("nestjs-pino");
|
18
18
|
const constants_1 = require("./constants");
|
19
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
19
20
|
let LoggerService = class LoggerService {
|
20
|
-
constructor(loggerOptions, logger) {
|
21
|
+
constructor(loggerOptions, logger, cls) {
|
21
22
|
this.loggerOptions = loggerOptions;
|
22
23
|
this.logger = logger;
|
24
|
+
this.cls = cls;
|
25
|
+
}
|
26
|
+
withAdditionalTraceId(meta) {
|
27
|
+
const xcTraceId = this.cls.get('xcTraceId');
|
28
|
+
const xcActionId = this.cls.get('xcActionId');
|
29
|
+
return { ...meta, xcTraceId, xcActionId };
|
23
30
|
}
|
24
31
|
debug(msg, meta) {
|
25
|
-
this.logger.debug({ meta, ...this.loggerOptions }, msg);
|
32
|
+
this.logger.debug({ meta: this.withAdditionalTraceId(meta), ...this.loggerOptions }, msg);
|
26
33
|
}
|
27
34
|
warn(msg, meta) {
|
28
|
-
this.logger.warn({ meta, ...this.loggerOptions }, msg);
|
35
|
+
this.logger.warn({ meta: this.withAdditionalTraceId(meta), ...this.loggerOptions }, msg);
|
29
36
|
}
|
30
37
|
error(msg, meta) {
|
31
|
-
this.logger.error({ meta, ...this.loggerOptions }, msg);
|
38
|
+
this.logger.error({ meta: this.withAdditionalTraceId(meta), ...this.loggerOptions }, msg);
|
32
39
|
}
|
33
40
|
fatal(msg, meta) {
|
34
|
-
this.logger.fatal({ meta, ...this.loggerOptions }, msg);
|
41
|
+
this.logger.fatal({ meta: this.withAdditionalTraceId(meta), ...this.loggerOptions }, msg);
|
35
42
|
}
|
36
43
|
info(msg, meta) {
|
37
|
-
this.logger.info({ meta, ...this.loggerOptions }, msg);
|
44
|
+
this.logger.info({ meta: this.withAdditionalTraceId(meta), ...this.loggerOptions }, msg);
|
38
45
|
}
|
39
46
|
trace(msg, meta) {
|
40
|
-
this.logger.trace({ meta, ...this.loggerOptions }, msg);
|
47
|
+
this.logger.trace({ meta: this.withAdditionalTraceId(meta), ...this.loggerOptions }, msg);
|
48
|
+
}
|
49
|
+
someMethod() {
|
50
|
+
this.cls.run(() => {
|
51
|
+
this.cls.set('xcTraceId', 'my-trace-id');
|
52
|
+
this.logger.info('Log con trace id');
|
53
|
+
setTimeout(() => {
|
54
|
+
this.logger.info('Anche qui funziona');
|
55
|
+
}, 100);
|
56
|
+
});
|
41
57
|
}
|
42
58
|
};
|
43
59
|
exports.LoggerService = LoggerService;
|
44
60
|
exports.LoggerService = LoggerService = __decorate([
|
45
61
|
(0, common_1.Injectable)(),
|
46
62
|
__param(0, (0, common_1.Inject)(constants_1.LOGGER_OPTIONS)),
|
47
|
-
__metadata("design:paramtypes", [Object, nestjs_pino_1.PinoLogger
|
63
|
+
__metadata("design:paramtypes", [Object, nestjs_pino_1.PinoLogger,
|
64
|
+
nestjs_cls_1.ClsService])
|
48
65
|
], LoggerService);
|
49
66
|
//# sourceMappingURL=logger.service.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAyC;AACzC,2CAA6C;
|
1
|
+
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAyC;AACzC,2CAA6C;AAE7C,2CAAwC;AAYjC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAC2C,aAAkC,EAC1D,MAAkB,EAClB,GAAe;QAFS,kBAAa,GAAb,aAAa,CAAqB;QAC1D,WAAM,GAAN,MAAM,CAAY;QAClB,QAAG,GAAH,GAAG,CAAY;IAC/B,CAAC;IAEI,qBAAqB,CAAC,IAAiB;QAC7C,MAAM,SAAS,GAAuB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChE,MAAM,UAAU,GAAuB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAClE,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,UAAU,EAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,IAAiB;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,CAAC,GAAW,EAAE,IAAiB;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,q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