xcally-nest-library 0.0.18 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,2 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import 'dotenv/config';
3
1
  export declare class LoggerModule {
4
- static forRoot(): DynamicModule;
5
2
  }
@@ -5,85 +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
- require("dotenv/config");
16
- const options = {
17
- resourceAttributes: {
18
- 'service.name': process.env.npm_package_name || 'unknown',
19
- },
20
- logRecordProcessorOptions: [
21
- {
22
- recordProcessorType: 'batch',
23
- exporterOptions: {
24
- protocol: 'http',
25
- httpExporterOptions: {
26
- url: new URL('v1/logs', process.env.OTLP_HTTP_URL || 'http://localhost:4318/').toString(),
27
- },
28
- },
29
- },
30
- ],
31
- loggerName: (process.env.npm_package_name || 'unknown') + '-logger',
32
- serviceVersion: process.env.npm_package_version || 'unknown',
14
+ let LoggerModule = class LoggerModule {
33
15
  };
34
- let LoggerModule = LoggerModule_1 = class LoggerModule {
35
- static forRoot() {
36
- return {
37
- module: LoggerModule_1,
38
- providers: [logger_service_1.LoggerService],
39
- exports: [logger_service_1.LoggerService],
40
- imports: [
41
- nestjs_pino_1.LoggerModule.forRootAsync({
42
- imports: [config_1.ConfigModule],
43
- inject: [config_1.ConfigService],
44
- useFactory: async (config) => {
45
- const projectName = process.env.npm_package_name || 'default_project';
46
- return {
47
- pinoHttp: {
48
- level: config.get('LOG_LEVEL') || 'info',
49
- redact: {
50
- paths: ['req.headers.cookie', 'req.headers.authorization'],
51
- },
52
- transport: {
53
- targets: [
54
- {
55
- target: 'pino-opentelemetry-transport',
56
- options,
57
- },
58
- {
59
- level: 'debug',
60
- target: 'pino-pretty',
61
- options: {
62
- colorize: true,
63
- },
16
+ exports.LoggerModule = LoggerModule;
17
+ exports.LoggerModule = LoggerModule = __decorate([
18
+ (0, common_1.Global)(),
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,
64
48
  },
65
- {
66
- level: 'info',
67
- target: 'pino/file',
68
- options: {
69
- destination: `./logs/${projectName}-info.log`,
70
- mkdir: true,
71
- append: process.env.NODE_ENV !== 'production' ? false : true,
72
- },
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,
73
57
  },
74
- ],
75
- },
58
+ },
59
+ ],
76
60
  },
77
- };
78
- },
79
- }),
80
- ],
81
- };
82
- }
83
- };
84
- exports.LoggerModule = LoggerModule;
85
- exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
86
- (0, common_1.Global)(),
87
- (0, common_1.Module)({})
61
+ },
62
+ };
63
+ },
64
+ }),
65
+ ],
66
+ })
88
67
  ], LoggerModule);
89
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;AACjD,yBAAuB;AAEvB,MAAM,OAAO,GAAY;IACvB,kBAAkB,EAAE;QAClB,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS;KAE1D;IACD,yBAAyB,EAAE;QACzB;YACE,mBAAmB,EAAE,OAAO;YAC5B,eAAe,EAAE;gBACf,QAAQ,EAAE,MAAM;gBAChB,mBAAmB,EAAE;oBACnB,GAAG,EAAE,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,wBAAwB,CAAC,CAAC,QAAQ,EAAE;iBAC1F;aACF;SACF;KAcF;IACD,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,CAAC,GAAG,SAAS;IACnE,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,SAAS;CAC7D,CAAC;AAGK,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,MAAM,EAAE,8BAA8B;4CACtC,OAAO;yCACR;wCACD;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;AAtEY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CAsExB"}
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;Q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