nestjs-pino 2.3.0-alpha.ce2e1c → 2.3.1
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/Logger.d.ts +19 -0
- package/Logger.js +30 -0
- package/package.json +1 -1
package/Logger.d.ts
CHANGED
|
@@ -11,4 +11,23 @@ export declare class Logger implements LoggerService {
|
|
|
11
11
|
warn(message: any, ...optionalParams: any[]): void;
|
|
12
12
|
error(message: any, ...optionalParams: any[]): void;
|
|
13
13
|
private call;
|
|
14
|
+
/**
|
|
15
|
+
* Unfortunately built-in (not only) `^.*Exception(s?)Handler$` classes call `.error`
|
|
16
|
+
* method with not supported contract:
|
|
17
|
+
*
|
|
18
|
+
* - ExceptionsHandler
|
|
19
|
+
* @see https://github.com/nestjs/nest/blob/35baf7a077bb972469097c5fea2f184b7babadfc/packages/core/exceptions/base-exception-filter.ts#L60-L63
|
|
20
|
+
*
|
|
21
|
+
* - ExceptionHandler
|
|
22
|
+
* @see https://github.com/nestjs/nest/blob/99ee3fd99341bcddfa408d1604050a9571b19bc9/packages/core/errors/exception-handler.ts#L9
|
|
23
|
+
*
|
|
24
|
+
* - WsExceptionsHandler
|
|
25
|
+
* @see https://github.com/nestjs/nest/blob/9d0551ff25c5085703bcebfa7ff3b6952869e794/packages/websockets/exceptions/base-ws-exception-filter.ts#L47-L50
|
|
26
|
+
*
|
|
27
|
+
* - RpcExceptionsHandler @see https://github.com/nestjs/nest/blob/9d0551ff25c5085703bcebfa7ff3b6952869e794/packages/microservices/exceptions/base-rpc-exception-filter.ts#L26-L30
|
|
28
|
+
*
|
|
29
|
+
* - all of them
|
|
30
|
+
* @see https://github.com/search?l=TypeScript&q=org%3Anestjs+logger+error+stack&type=Code
|
|
31
|
+
*/
|
|
32
|
+
private isWrongExceptionsHandlerContract;
|
|
14
33
|
}
|
package/Logger.js
CHANGED
|
@@ -54,10 +54,40 @@ let Logger = class Logger {
|
|
|
54
54
|
}
|
|
55
55
|
this.logger[level](objArg, ...params);
|
|
56
56
|
}
|
|
57
|
+
else if (this.isWrongExceptionsHandlerContract(level, message, params)) {
|
|
58
|
+
objArg.err = new Error(message);
|
|
59
|
+
objArg.err.stack = params[0];
|
|
60
|
+
this.logger[level](objArg);
|
|
61
|
+
}
|
|
57
62
|
else {
|
|
58
63
|
this.logger[level](objArg, message, ...params);
|
|
59
64
|
}
|
|
60
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Unfortunately built-in (not only) `^.*Exception(s?)Handler$` classes call `.error`
|
|
68
|
+
* method with not supported contract:
|
|
69
|
+
*
|
|
70
|
+
* - ExceptionsHandler
|
|
71
|
+
* @see https://github.com/nestjs/nest/blob/35baf7a077bb972469097c5fea2f184b7babadfc/packages/core/exceptions/base-exception-filter.ts#L60-L63
|
|
72
|
+
*
|
|
73
|
+
* - ExceptionHandler
|
|
74
|
+
* @see https://github.com/nestjs/nest/blob/99ee3fd99341bcddfa408d1604050a9571b19bc9/packages/core/errors/exception-handler.ts#L9
|
|
75
|
+
*
|
|
76
|
+
* - WsExceptionsHandler
|
|
77
|
+
* @see https://github.com/nestjs/nest/blob/9d0551ff25c5085703bcebfa7ff3b6952869e794/packages/websockets/exceptions/base-ws-exception-filter.ts#L47-L50
|
|
78
|
+
*
|
|
79
|
+
* - RpcExceptionsHandler @see https://github.com/nestjs/nest/blob/9d0551ff25c5085703bcebfa7ff3b6952869e794/packages/microservices/exceptions/base-rpc-exception-filter.ts#L26-L30
|
|
80
|
+
*
|
|
81
|
+
* - all of them
|
|
82
|
+
* @see https://github.com/search?l=TypeScript&q=org%3Anestjs+logger+error+stack&type=Code
|
|
83
|
+
*/
|
|
84
|
+
isWrongExceptionsHandlerContract(level, message, params) {
|
|
85
|
+
return (level === 'error' &&
|
|
86
|
+
typeof message === 'string' &&
|
|
87
|
+
params.length === 1 &&
|
|
88
|
+
typeof params[0] === 'string' &&
|
|
89
|
+
/\n\s*at /.test(params[0]));
|
|
90
|
+
}
|
|
61
91
|
};
|
|
62
92
|
Logger = __decorate([
|
|
63
93
|
(0, common_1.Injectable)(),
|