@dotcom-reliability-kit/middleware-log-errors
Advanced tools
Comparing version 1.2.12 to 1.3.0
{ | ||
"name": "@dotcom-reliability-kit/middleware-log-errors", | ||
"version": "1.2.12", | ||
"version": "1.3.0", | ||
"description": "Express middleware to consistently log errors", | ||
@@ -19,3 +19,3 @@ "repository": { | ||
"dependencies": { | ||
"@dotcom-reliability-kit/log-error": "^1.3.11" | ||
"@dotcom-reliability-kit/log-error": "^1.4.0" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
@@ -90,5 +90,18 @@ | ||
An array of request headers to include in the serialized request object. This must be an `Array` of `String`s, with each string being a header name. It's important that you do not include headers which include personally-identifiable-information, API keys, or other privileged information. This defaults to `['accept', 'content-type']`. This option gets passed directly into [`dotcom-reliability-kit/serialize-request`](https://github.com/Financial-Times/dotcom-reliability-kit/tree/main/packages/serialize-request#readme) which has further documentation. | ||
An array of request headers to include in the serialized request object. This must be an `Array` of `String`s, with each string being a header name. It's important that you do not include headers which include personally-identifiable-information, API keys, or other privileged information. This option gets passed directly into [`dotcom-reliability-kit/serialize-request`](https://github.com/Financial-Times/dotcom-reliability-kit/tree/main/packages/serialize-request#readme) which has further documentation. | ||
This option defaults to: | ||
```js | ||
[ | ||
'accept', | ||
'accept-encoding', | ||
'accept-language', | ||
'content-type', | ||
'referer', | ||
'user-agent' | ||
] | ||
``` | ||
Example of usage: | ||
```js | ||
app.use(createErrorLogger({ | ||
@@ -104,2 +117,15 @@ includeHeaders: [ | ||
The default set of headers is also available to use, so that you don't need to repeat them if you want to add new included headers. You'll need to import `@dotcom-reliability-kit/serialize-request`, then these headers are available: | ||
```js | ||
const { DEFAULT_INCLUDED_HEADERS } = require('@dotcom-reliability-kit/serialize-request'); | ||
app.use(createErrorLogger({ | ||
includeHeaders: [ | ||
...DEFAULT_INCLUDED_HEADERS, | ||
'my-custom-header' | ||
] | ||
})); | ||
``` | ||
> **Note** | ||
@@ -106,0 +132,0 @@ > There's no need to include the `x-request-id` header in this array, as this is automatically included as `request.id` in the logs. |
7810
142