nestjs-pino 2.3.0-alpha.ce2e1c → 2.3.1-alpha.0c53ca
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/README.md +1 -1
- package/package.json +2 -2
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)(),
|
package/README.md
CHANGED
|
@@ -233,7 +233,7 @@ import { LoggerModule } from 'nestjs-pino';
|
|
|
233
233
|
// install 'pino-pretty' package in order to use the following option
|
|
234
234
|
transport: process.env.NODE_ENV !== 'production'
|
|
235
235
|
? { target: 'pino-pretty' }
|
|
236
|
-
:
|
|
236
|
+
: undefined,
|
|
237
237
|
useLevelLabels: true,
|
|
238
238
|
// and all the others...
|
|
239
239
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-pino",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1-alpha.0c53ca",
|
|
4
4
|
"description": "Pino logger for NestJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"eslint-config-prettier": "^8.3.0",
|
|
56
56
|
"eslint-plugin-import": "^2.24.2",
|
|
57
57
|
"eslint-plugin-prettier": "^4.0.0",
|
|
58
|
-
"jest": "27.3
|
|
58
|
+
"jest": "27.4.3",
|
|
59
59
|
"memorystream": "^0.3.1",
|
|
60
60
|
"pino-http": "^6.0.0",
|
|
61
61
|
"prettier": "^2.3.2",
|