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.
@@ -1,4 +1,2 @@
1
- import { DynamicModule } from '@nestjs/common';
2
1
  export declare class LoggerModule {
3
- static forRoot(): DynamicModule;
4
2
  }
@@ -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 = LoggerModule_1 = class 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 = LoggerModule_1 = __decorate([
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":";;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AAI1C,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,SAAS,EAAE,CAAC,8BAAa,CAAC;YAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;YACxB,OAAO,EAAE;gBACP,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,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,iBAAiB,CAAC;wBACtE,OAAO;4BACL,QAAQ,EAAE;gCACR,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,MAAM;gCAWxC,MAAM,EAAE;oCACN,KAAK,EAAE,CAAC,oBAAoB,EAAE,2BAA2B,CAAC;iCAC3D;gCACD,SAAS,EAAE;oCACT,OAAO,EAAE;wCACP;4CACE,KAAK,EAAE,OAAO;4CACd,MAAM,EAAE,aAAa;4CACrB,OAAO,EAAE;gDACP,QAAQ,EAAE,IAAI;6CACf;yCACF;wCAQD;4CACE,KAAK,EAAE,MAAM;4CACb,MAAM,EAAE,WAAW;4CACnB,OAAO,EAAE;gDACP,WAAW,EAAE,UAAU,WAAW,WAAW;gDAC7C,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;AAlEY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CAkExB"}
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,qDAA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