xcally-nest-library 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/modules/logger/pino/logger.module.d.ts +0 -2
- package/dist/src/modules/logger/pino/logger.module.js +50 -48
- package/dist/src/modules/logger/pino/logger.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modules/logger/pino/logger.module.ts +66 -66
@@ -5,62 +5,64 @@ 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;
|
9
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
9
|
exports.LoggerModule = void 0;
|
11
10
|
const common_1 = require("@nestjs/common");
|
12
11
|
const config_1 = require("@nestjs/config");
|
13
12
|
const nestjs_pino_1 = require("nestjs-pino");
|
14
13
|
const logger_service_1 = require("./logger.service");
|
15
|
-
let LoggerModule =
|
16
|
-
static forRoot() {
|
17
|
-
return {
|
18
|
-
module: LoggerModule_1,
|
19
|
-
providers: [logger_service_1.LoggerService],
|
20
|
-
exports: [logger_service_1.LoggerService],
|
21
|
-
imports: [
|
22
|
-
nestjs_pino_1.LoggerModule.forRootAsync({
|
23
|
-
imports: [config_1.ConfigModule],
|
24
|
-
inject: [config_1.ConfigService],
|
25
|
-
useFactory: async (config) => {
|
26
|
-
const projectName = process.env.npm_package_name || 'default_project';
|
27
|
-
return {
|
28
|
-
pinoHttp: {
|
29
|
-
level: config.get('LOG_LEVEL') || 'info',
|
30
|
-
redact: {
|
31
|
-
paths: ['req.headers.cookie', 'req.headers.authorization'],
|
32
|
-
},
|
33
|
-
transport: {
|
34
|
-
targets: [
|
35
|
-
{
|
36
|
-
level: 'debug',
|
37
|
-
target: 'pino-pretty',
|
38
|
-
options: {
|
39
|
-
colorize: true,
|
40
|
-
},
|
41
|
-
},
|
42
|
-
{
|
43
|
-
level: 'info',
|
44
|
-
target: 'pino/file',
|
45
|
-
options: {
|
46
|
-
destination: `./logs/${projectName}-info.log`,
|
47
|
-
mkdir: true,
|
48
|
-
append: process.env.NODE_ENV !== 'production' ? false : true,
|
49
|
-
},
|
50
|
-
},
|
51
|
-
],
|
52
|
-
},
|
53
|
-
},
|
54
|
-
};
|
55
|
-
},
|
56
|
-
}),
|
57
|
-
],
|
58
|
-
};
|
59
|
-
}
|
14
|
+
let LoggerModule = class LoggerModule {
|
60
15
|
};
|
61
16
|
exports.LoggerModule = LoggerModule;
|
62
|
-
exports.LoggerModule = LoggerModule =
|
17
|
+
exports.LoggerModule = LoggerModule = __decorate([
|
63
18
|
(0, common_1.Global)(),
|
64
|
-
(0, common_1.Module)({
|
19
|
+
(0, common_1.Module)({
|
20
|
+
providers: [logger_service_1.LoggerService],
|
21
|
+
exports: [logger_service_1.LoggerService],
|
22
|
+
imports: [
|
23
|
+
nestjs_pino_1.LoggerModule.forRootAsync({
|
24
|
+
imports: [config_1.ConfigModule],
|
25
|
+
inject: [config_1.ConfigService],
|
26
|
+
useFactory: async (config) => {
|
27
|
+
const projectName = process.env.npm_package_name || 'default_project';
|
28
|
+
return {
|
29
|
+
pinoHttp: {
|
30
|
+
customLogLevel: (req, res) => {
|
31
|
+
if (res.statusCode >= 500)
|
32
|
+
return 'error';
|
33
|
+
if (res.statusCode >= 400)
|
34
|
+
return 'warn';
|
35
|
+
return 'info';
|
36
|
+
},
|
37
|
+
level: config.get('LOG_LEVEL') || 'info',
|
38
|
+
redact: {
|
39
|
+
paths: ['req.headers.cookie', 'req.headers.authorization'],
|
40
|
+
},
|
41
|
+
transport: {
|
42
|
+
targets: [
|
43
|
+
{
|
44
|
+
level: 'debug',
|
45
|
+
target: 'pino-pretty',
|
46
|
+
options: {
|
47
|
+
colorize: true,
|
48
|
+
},
|
49
|
+
},
|
50
|
+
{
|
51
|
+
level: 'info',
|
52
|
+
target: 'pino/file',
|
53
|
+
options: {
|
54
|
+
destination: `./logs/${projectName}-info.log`,
|
55
|
+
mkdir: true,
|
56
|
+
append: process.env.NODE_ENV !== 'production' ? false : true,
|
57
|
+
},
|
58
|
+
},
|
59
|
+
],
|
60
|
+
},
|
61
|
+
},
|
62
|
+
};
|
63
|
+
},
|
64
|
+
}),
|
65
|
+
],
|
66
|
+
})
|
65
67
|
], LoggerModule);
|
66
68
|
//# 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,2CAAgD;AAChD,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AAsE1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IApExB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;QACxB,OAAO,EAAE;YACP,0BAAgB,CAAC,YAAY,CAAC;gBAC5B,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;gBACvB,UAAU,EAAE,KAAK,EAAE,MAAqB,EAAE,EAAE;oBAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,iBAAiB,CAAC;oBACtE,OAAO;wBACL,QAAQ,EAAE;4BACR,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gCAC3B,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG;oCAAE,OAAO,OAAO,CAAC;gCAC1C,IAAI,GAAG,CAAC,UAAU,IAA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