Gathering detailed insights and metrics for @edgeros/pino-std-serializers
Gathering detailed insights and metrics for @edgeros/pino-std-serializers
Gathering detailed insights and metrics for @edgeros/pino-std-serializers
Gathering detailed insights and metrics for @edgeros/pino-std-serializers
npm install @edgeros/pino-std-serializers
Typescript
Module System
Node Version
NPM Version
73.2
Supply Chain
98.4
Quality
80
Maintenance
100
Vulnerability
100
License
Total Downloads
239
Last Day
2
Last Week
2
Last Month
11
Last Year
130
Latest Version
6.2.2
Package Id
@edgeros/pino-std-serializers@6.2.2
Unpacked Size
47.74 kB
Size
8.83 kB
File Count
20
NPM Version
@edgeros/pino-std-serializers@6.2.2
Node Version
16.15.0
Published on
Dec 16, 2023
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
100%
2
Compared to previous week
Last Month
83.3%
11
Compared to previous month
Last Year
19.3%
130
Compared to previous year
1
7
exports.err(error)
Serializes an Error
like object. Returns an object:
1{ 2 type: 'string', // The name of the object's constructor. 3 message: 'string', // The supplied error message. 4 stack: 'string', // The stack when the error was generated. 5 raw: Error // Non-enumerable, i.e. will not be in the output, original 6 // Error object. This is available for subsequent serializers 7 // to use. 8 [...any additional Enumerable property the original Error had] 9}
Example:
1const serializer = require('pino-std-serializers').err; 2 3const innerError = new Error("inner error"); 4innerError.isInner = true; 5const outerError = new Error("outer error", { cause: innerError }); 6outerError.isInner = false; 7 8const serialized = serializer(outerError); 9/* Result: 10{ 11 "type": "Error", 12 "message": "outer error: inner error", 13 "isInner": false, 14 "stack": "Error: outer error 15 at <...omitted..> 16 caused by: Error: inner error 17 at <...omitted..> 18} 19 */ 20 21### `exports.errWithCause(error)` 22Serializes an `Error` like object, including any `error.cause`. Returns an object: 23 24```js 25{ 26 type: 'string', // The name of the object's constructor. 27 message: 'string', // The supplied error message. 28 stack: 'string', // The stack when the error was generated. 29 cause?: Error, // If the original error had an error.cause, it will be serialized here 30 raw: Error // Non-enumerable, i.e. will not be in the output, original 31 // Error object. This is available for subsequent serializers 32 // to use. 33 [...any additional Enumerable property the original Error had] 34}
Any other extra properties, e.g. statusCode
, that have been attached to the object will also be present on the serialized object.
Example:
1const serializer = require('pino-std-serializers').errWithCause; 2 3const innerError = new Error("inner error"); 4innerError.isInner = true; 5const outerError = new Error("outer error", { cause: innerError }); 6outerError.isInner = false; 7 8const serialized = serializer(outerError); 9/* Result: 10{ 11 "type": "Error", 12 "message": "outer error", 13 "isInner": false, 14 "stack": "Error: outer error 15 at <...omitted..>", 16 "cause": { 17 "type": "Error", 18 "message": "inner error", 19 "isInner": true, 20 "stack": "Error: inner error 21 at <...omitted..>" 22 }, 23} 24 */
exports.mapHttpResponse(response)
Used internally by Pino for general response logging. Returns an object:
1{ 2 res: {} 3}
Where res
is the response
as serialized by the standard response serializer.
exports.mapHttpRequest(request)
Used internall by Pino for general request logging. Returns an object:
1{ 2 req: {} 3}
Where req
is the request
as serialized by the standard request serializer.
exports.req(request)
The default request
serializer. Returns an object:
1{ 2 id: 'string', // Defaults to `undefined`, unless there is an `id` property 3 // already attached to the `request` object or to the `request.info` 4 // object. Attach a synchronous function 5 // to the `request.id` that returns an identifier to have 6 // the value filled. 7 method: 'string', 8 url: 'string', // the request pathname (as per req.url in core HTTP) 9 query: 'object', // the request query (as per req.query in express or hapi) 10 params: 'object', // the request params (as per req.params in express or hapi) 11 headers: Object, // a reference to the `headers` object from the request 12 // (as per req.headers in core HTTP) 13 remoteAddress: 'string', 14 remotePort: Number, 15 raw: Object // Non-enumerable, i.e. will not be in the output, original 16 // request object. This is available for subsequent serializers 17 // to use. In cases where the `request` input already has 18 // a `raw` property this will replace the original `request.raw` 19 // property 20}
exports.res(response)
The default response
serializer. Returns an object:
1{ 2 statusCode: Number, // Response status code, will be null before headers are flushed 3 headers: Object, // The headers to be sent in the response. 4 raw: Object // Non-enumerable, i.e. will not be in the output, original 5 // response object. This is available for subsequent serializers 6 // to use. 7}
MIT License
No vulnerabilities found.
No security vulnerabilities found.