https://github.com/gajus/roarr-middleware-serialize-error
Serializes error objects in the Roarr message context.
https://github.com/gajus/roarr-middleware-serialize-error
log middleware roarr
Last synced: 3 months ago
JSON representation
Serializes error objects in the Roarr message context.
- Host: GitHub
- URL: https://github.com/gajus/roarr-middleware-serialize-error
- Owner: gajus
- License: other
- Created: 2018-07-18T12:22:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-24T09:44:11.000Z (over 6 years ago)
- Last Synced: 2025-01-08T12:50:31.958Z (6 months ago)
- Topics: log, middleware, roarr
- Language: JavaScript
- Size: 6.84 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @roarr/middleware-serialize-error
[](https://travis-ci.org/gajus/roarr-middleware-serialize-error)
[](https://coveralls.io/github/gajus/roarr-middleware-serialize-error)
[](https://www.npmjs.com/package/@roarr/middleware-serialize-error)
[](https://github.com/gajus/canonical)
[](https://twitter.com/kuizinas)Serializes error objects in the [Roarr](https://github.com/gajus/roarr) message context.
## Behaviour
The current implementation maps only the direct context properties.
Raise an issue if you have a use case that requires deep property mapping.
## Usage
```js
import log from 'roarr';
import createSerializeErrorMiddleware from '@roarr/middleware-serialize-error';const childLog = log
.child({name: 'foo'})
.child(createSerializeErrorMiddleware());const error = new Error('foo');
log.debug({error}, 'bar');
childLog.debug({error}, 'bar');// {"context":{"logLevel":20,"error":{}},"message":"bar","sequence":0,"time":1531918373676,"version":"1.0.0"}
// {"context":{"logLevel":20,"error":{"name":"Error","message":"foo","stack":"[REDACTED]"}},"message":"bar","sequence":1,"time":1531918373678,"version":"1.0.0"}```