xcally-nest-library 0.0.31 → 0.0.33
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/core/infrastracture/databases/base.entity.d.ts +1 -2
- package/dist/src/core/infrastracture/databases/base.entity.js +1 -2
- package/dist/src/core/infrastracture/databases/base.entity.js.map +1 -1
- package/dist/src/modules/logger/pino/constants.d.ts +1 -0
- package/dist/src/modules/logger/pino/constants.js +5 -0
- package/dist/src/modules/logger/pino/constants.js.map +1 -0
- package/dist/src/modules/logger/pino/logger.module.d.ts +11 -0
- package/dist/src/modules/logger/pino/logger.module.js +63 -52
- package/dist/src/modules/logger/pino/logger.module.js.map +1 -1
- package/dist/src/modules/logger/pino/logger.service.d.ts +3 -1
- package/dist/src/modules/logger/pino/logger.service.js +14 -8
- package/dist/src/modules/logger/pino/logger.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/modules/logger/pino/constants.ts +1 -0
- package/src/modules/logger/pino/logger.module.ts +89 -67
- package/src/modules/logger/pino/logger.service.ts +13 -8
@@ -1,5 +1,4 @@
|
|
1
|
-
import { UpdateEvent } from 'typeorm';
|
2
|
-
import { EntitySubscriberInterface, InsertEvent } from 'typeorm';
|
1
|
+
import { EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
3
2
|
import { IBaseEntity } from './base.entity.interface';
|
4
3
|
export declare class BaseEntity implements IBaseEntity {
|
5
4
|
id: number;
|
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.BaseEntitySubscriber = exports.BaseEntity = void 0;
|
13
13
|
const typeorm_1 = require("typeorm");
|
14
|
-
const typeorm_2 = require("typeorm");
|
15
14
|
class BaseEntity {
|
16
15
|
}
|
17
16
|
exports.BaseEntity = BaseEntity;
|
@@ -49,6 +48,6 @@ let BaseEntitySubscriber = class BaseEntitySubscriber {
|
|
49
48
|
};
|
50
49
|
exports.BaseEntitySubscriber = BaseEntitySubscriber;
|
51
50
|
exports.BaseEntitySubscriber = BaseEntitySubscriber = __decorate([
|
52
|
-
(0,
|
51
|
+
(0, typeorm_1.EventSubscriber)()
|
53
52
|
], BaseEntitySubscriber);
|
54
53
|
//# sourceMappingURL=base.entity.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base.entity.js","sourceRoot":"","sources":["../../../../../src/core/infrastracture/databases/base.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"base.entity.js","sourceRoot":"","sources":["../../../../../src/core/infrastracture/databases/base.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAQiB;AAGjB,MAAa,UAAU;CAatB;AAbD,gCAaC;AAXC;IADC,IAAA,gCAAsB,GAAE;;sCACd;AAKX;IAHC,IAAA,0BAAgB,EAAC;QAChB,IAAI,EAAE,UAAU;KACjB,CAAC;8BACS,IAAI;6CAAC;AAKhB;IAHC,IAAA,0BAAgB,EAAC;QAChB,IAAI,EAAE,UAAU;KACjB,CAAC;8BACS,IAAI;6CAAC;AAIX,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAIxB,QAAQ;QACb,OAAO,UAAU,CAAC;IACpB,CAAC;IAKM,YAAY,CAAC,KAA8B;QAChD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACxD,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC;QAC7B,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,KAA8B;QAChD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACxD,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC;IAC/B,CAAC;CACF,CAAA;AAvBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,yBAAe,GAAE;GACL,oBAAoB,CAuBhC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const LOGGER_OPTIONS = "LOGGER_OPTIONS";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,gBAAgB,CAAC"}
|
@@ -1,2 +1,13 @@
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
2
|
+
export interface LoggerModuleOptions {
|
3
|
+
'resource.service.name': string;
|
4
|
+
'resource.service.namespace': string;
|
5
|
+
'resource.service.version'?: string;
|
6
|
+
'resource.service.environment'?: string;
|
7
|
+
'resource.service.deployment.environment'?: string;
|
8
|
+
'resource.service.deployment.id'?: string;
|
9
|
+
'resource.service.deployment.revision'?: string;
|
10
|
+
}
|
1
11
|
export declare class LoggerModule {
|
12
|
+
static forRoot(options: LoggerModuleOptions): DynamicModule;
|
2
13
|
}
|
@@ -5,66 +5,77 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
7
|
};
|
8
|
+
var LoggerModule_1;
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
10
|
exports.LoggerModule = void 0;
|
10
11
|
const common_1 = require("@nestjs/common");
|
11
12
|
const config_1 = require("@nestjs/config");
|
12
13
|
const nestjs_pino_1 = require("nestjs-pino");
|
13
14
|
const logger_service_1 = require("./logger.service");
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
15
|
+
const constants_1 = require("./constants");
|
16
|
+
let LoggerModule = LoggerModule_1 = class LoggerModule {
|
17
|
+
static forRoot(options) {
|
18
|
+
const loggerOptions = {
|
19
|
+
provide: constants_1.LOGGER_OPTIONS,
|
20
|
+
useValue: options,
|
21
|
+
};
|
22
|
+
const providers = [logger_service_1.LoggerService, loggerOptions];
|
23
|
+
const exports = [logger_service_1.LoggerService, loggerOptions];
|
24
|
+
return {
|
25
|
+
module: LoggerModule_1,
|
26
|
+
providers,
|
27
|
+
exports,
|
28
|
+
imports: [
|
29
|
+
nestjs_pino_1.LoggerModule.forRootAsync({
|
30
|
+
imports: [config_1.ConfigModule],
|
31
|
+
inject: [config_1.ConfigService],
|
32
|
+
useFactory: async (config) => {
|
33
|
+
const projectName = process.env.npm_package_name || 'default_project';
|
34
|
+
return {
|
35
|
+
pinoHttp: {
|
36
|
+
customLogLevel: (req, res) => {
|
37
|
+
if (res.statusCode >= 500)
|
38
|
+
return 'error';
|
39
|
+
if (res.statusCode >= 400)
|
40
|
+
return 'warn';
|
41
|
+
return 'info';
|
42
|
+
},
|
43
|
+
level: config.get('LOG_LEVEL') || 'info',
|
44
|
+
redact: {
|
45
|
+
paths: ['req.headers.cookie', 'req.headers.authorization'],
|
46
|
+
},
|
47
|
+
transport: {
|
48
|
+
targets: [
|
49
|
+
{
|
50
|
+
level: 'debug',
|
51
|
+
target: 'pino-pretty',
|
52
|
+
options: {
|
53
|
+
colorize: true,
|
54
|
+
},
|
48
55
|
},
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
:
|
57
|
-
|
58
|
-
|
56
|
+
{
|
57
|
+
level: config.get('LOG_LEVEL') || 'info',
|
58
|
+
target: 'pino/file',
|
59
|
+
options: {
|
60
|
+
destination: process.env.LOG_OUT_DIR
|
61
|
+
? process.env.LOG_OUT_DIR + `${projectName}.log`
|
62
|
+
: `./logs/${projectName}.log`,
|
63
|
+
mkdir: true,
|
64
|
+
append: process.env.NODE_ENV !== 'production' ? false : true,
|
65
|
+
},
|
59
66
|
},
|
60
|
-
|
61
|
-
|
67
|
+
],
|
68
|
+
},
|
62
69
|
},
|
63
|
-
}
|
64
|
-
}
|
65
|
-
},
|
66
|
-
|
67
|
-
|
68
|
-
}
|
70
|
+
};
|
71
|
+
},
|
72
|
+
}),
|
73
|
+
],
|
74
|
+
};
|
75
|
+
}
|
76
|
+
};
|
77
|
+
exports.LoggerModule = LoggerModule;
|
78
|
+
exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
|
79
|
+
(0, common_1.Global)()
|
69
80
|
], LoggerModule);
|
70
81
|
//# sourceMappingURL=logger.module.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":"
|
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;AAatC,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,M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DAChD,CAAC,CAAC,UAAU,WAAW,MAAM;gDAC/B,KAAK,EAAE,IAAI;gDACX,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;6CAC7D;yCACF;qCACF;iCACF;6BAKF;yBACF,CAAC;oBACJ,CAAC;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhFY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,eAAM,GAAE;GACI,YAAY,CAgFxB"}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { PinoLogger } from 'nestjs-pino';
|
2
|
+
import { LoggerModuleOptions } from './logger.module';
|
2
3
|
interface LoggerMeta {
|
3
4
|
ctx?: any;
|
4
5
|
[key: string]: any;
|
5
6
|
}
|
6
7
|
export declare class LoggerService {
|
8
|
+
private readonly loggerOptions;
|
7
9
|
private readonly logger;
|
8
|
-
constructor(logger: PinoLogger);
|
10
|
+
constructor(loggerOptions: LoggerModuleOptions, logger: PinoLogger);
|
9
11
|
debug(msg: string, meta?: LoggerMeta): void;
|
10
12
|
warn(msg: string, meta?: LoggerMeta): void;
|
11
13
|
error(msg: string, meta?: LoggerMeta): void;
|
@@ -8,36 +8,42 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
10
|
};
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.LoggerService = void 0;
|
13
16
|
const common_1 = require("@nestjs/common");
|
14
17
|
const nestjs_pino_1 = require("nestjs-pino");
|
18
|
+
const constants_1 = require("./constants");
|
15
19
|
let LoggerService = class LoggerService {
|
16
|
-
constructor(logger) {
|
20
|
+
constructor(loggerOptions, logger) {
|
21
|
+
this.loggerOptions = loggerOptions;
|
17
22
|
this.logger = logger;
|
18
23
|
}
|
19
24
|
debug(msg, meta) {
|
20
|
-
this.logger.debug({ meta }, msg);
|
25
|
+
this.logger.debug({ meta, ...this.loggerOptions }, msg);
|
21
26
|
}
|
22
27
|
warn(msg, meta) {
|
23
|
-
this.logger.warn({ meta }, msg);
|
28
|
+
this.logger.warn({ meta, ...this.loggerOptions }, msg);
|
24
29
|
}
|
25
30
|
error(msg, meta) {
|
26
|
-
this.logger.error({ meta }, msg);
|
31
|
+
this.logger.error({ meta, ...this.loggerOptions }, msg);
|
27
32
|
}
|
28
33
|
fatal(msg, meta) {
|
29
|
-
this.logger.fatal({ meta }, msg);
|
34
|
+
this.logger.fatal({ meta, ...this.loggerOptions }, msg);
|
30
35
|
}
|
31
36
|
info(msg, meta) {
|
32
|
-
this.logger.info({ meta }, msg);
|
37
|
+
this.logger.info({ meta, ...this.loggerOptions }, msg);
|
33
38
|
}
|
34
39
|
trace(msg, meta) {
|
35
|
-
this.logger.trace({ meta }, msg);
|
40
|
+
this.logger.trace({ meta, ...this.loggerOptions }, msg);
|
36
41
|
}
|
37
42
|
};
|
38
43
|
exports.LoggerService = LoggerService;
|
39
44
|
exports.LoggerService = LoggerService = __decorate([
|
40
45
|
(0, common_1.Injectable)(),
|
41
|
-
|
46
|
+
__param(0, (0, common_1.Inject)(constants_1.LOGGER_OPTIONS)),
|
47
|
+
__metadata("design:paramtypes", [Object, nestjs_pino_1.PinoLogger])
|
42
48
|
], LoggerService);
|
43
49
|
//# 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":"
|
1
|
+
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.service.ts"],"names":[],"mappings":";;;;;;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