@saihu/common 1.1.46 → 1.1.48

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.
@@ -1,5 +1,6 @@
1
1
  import { LoggerService } from '@nestjs/common';
2
2
  export declare class SaihuLogger implements LoggerService {
3
+ private shouldHideContext;
3
4
  log(message: any, context?: string): void;
4
5
  error(message: any, trace?: string, context?: string): void;
5
6
  warn(message: any, context?: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"saihu-logger.service.d.ts","sourceRoot":"","sources":["../../src/logger/saihu-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,WAAY,YAAW,aAAa;IAC/C,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBlC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBpD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBnC,KAAK;IACL,OAAO;CACR"}
1
+ {"version":3,"file":"saihu-logger.service.d.ts","sourceRoot":"","sources":["../../src/logger/saihu-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,WAAY,YAAW,aAAa;IAC/C,OAAO,CAAC,iBAAiB;IAqBzB,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAKlC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAKpD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAKnC,KAAK;IACL,OAAO;CACR"}
@@ -2,81 +2,37 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SaihuLogger = void 0;
4
4
  class SaihuLogger {
5
+ shouldHideContext(context) {
6
+ if (!context)
7
+ return false;
8
+ const hiddenContexts = [
9
+ 'InstanceLoader',
10
+ 'RoutesResolver',
11
+ 'RouterExplorer',
12
+ 'NestFactory',
13
+ 'NestApplication',
14
+ 'ClientProxy',
15
+ 'NestMicroservice',
16
+ 'AmqpConnection',
17
+ 'MicroserviceConfiguration',
18
+ 'RabbitMQModule',
19
+ 'WebSocketsController',
20
+ 'ExceptionsHandler', // ← Add this
21
+ ];
22
+ return hiddenContexts.some((hidden) => context.includes(hidden));
23
+ }
5
24
  log(message, context) {
6
- // Hide Nest internal logs
7
- if (context === null || context === void 0 ? void 0 : context.includes('InstanceLoader'))
8
- return;
9
- if (context === null || context === void 0 ? void 0 : context.includes('RoutesResolver'))
10
- return;
11
- if (context === null || context === void 0 ? void 0 : context.includes('RouterExplorer'))
12
- return;
13
- if (context === null || context === void 0 ? void 0 : context.includes('NestFactory'))
14
- return;
15
- if (context === null || context === void 0 ? void 0 : context.includes('NestApplication'))
16
- return;
17
- if (context === null || context === void 0 ? void 0 : context.includes('ClientProxy'))
18
- return;
19
- if (context === null || context === void 0 ? void 0 : context.includes('NestMicroservice'))
20
- return;
21
- if (context === null || context === void 0 ? void 0 : context.includes('AmqpConnection'))
22
- return;
23
- if (context === null || context === void 0 ? void 0 : context.includes('MicroserviceConfiguration'))
24
- return;
25
- if (context === null || context === void 0 ? void 0 : context.includes('RabbitMQModule'))
26
- return;
27
- if (context === null || context === void 0 ? void 0 : context.includes('WebSocketsController'))
25
+ if (this.shouldHideContext(context))
28
26
  return;
29
27
  console.log(`[${context}]`, message);
30
28
  }
31
29
  error(message, trace, context) {
32
- // Hide Nest internal errors
33
- if (context === null || context === void 0 ? void 0 : context.includes('InstanceLoader'))
34
- return;
35
- if (context === null || context === void 0 ? void 0 : context.includes('RoutesResolver'))
36
- return;
37
- if (context === null || context === void 0 ? void 0 : context.includes('RouterExplorer'))
38
- return;
39
- if (context === null || context === void 0 ? void 0 : context.includes('NestFactory'))
40
- return;
41
- if (context === null || context === void 0 ? void 0 : context.includes('NestApplication'))
42
- return;
43
- if (context === null || context === void 0 ? void 0 : context.includes('ClientProxy'))
44
- return;
45
- if (context === null || context === void 0 ? void 0 : context.includes('NestMicroservice'))
46
- return;
47
- if (context === null || context === void 0 ? void 0 : context.includes('AmqpConnection'))
48
- return;
49
- if (context === null || context === void 0 ? void 0 : context.includes('MicroserviceConfiguration'))
50
- return;
51
- if (context === null || context === void 0 ? void 0 : context.includes('RabbitMQModule'))
52
- return;
53
- if (context === null || context === void 0 ? void 0 : context.includes('WebSocketsController'))
30
+ if (this.shouldHideContext(context))
54
31
  return;
55
32
  console.error(`[${context}]`, message, trace);
56
33
  }
57
34
  warn(message, context) {
58
- // Hide Nest internal warnings
59
- if (context === null || context === void 0 ? void 0 : context.includes('InstanceLoader'))
60
- return;
61
- if (context === null || context === void 0 ? void 0 : context.includes('RoutesResolver'))
62
- return;
63
- if (context === null || context === void 0 ? void 0 : context.includes('RouterExplorer'))
64
- return;
65
- if (context === null || context === void 0 ? void 0 : context.includes('NestFactory'))
66
- return;
67
- if (context === null || context === void 0 ? void 0 : context.includes('NestApplication'))
68
- return;
69
- if (context === null || context === void 0 ? void 0 : context.includes('ClientProxy'))
70
- return;
71
- if (context === null || context === void 0 ? void 0 : context.includes('NestMicroservice'))
72
- return;
73
- if (context === null || context === void 0 ? void 0 : context.includes('AmqpConnection'))
74
- return;
75
- if (context === null || context === void 0 ? void 0 : context.includes('MicroserviceConfiguration'))
76
- return;
77
- if (context === null || context === void 0 ? void 0 : context.includes('RabbitMQModule'))
78
- return;
79
- if (context === null || context === void 0 ? void 0 : context.includes('WebSocketsController'))
35
+ if (this.shouldHideContext(context))
80
36
  return;
81
37
  console.warn(`[${context}]`, message);
82
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saihu/common",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
4
4
  "description": "Common utilities for NestJS applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",