express-pino-logger
Advanced tools
Comparing version 5.0.0 to 6.0.0
{ | ||
"name": "express-pino-logger", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "An express middleware to log with pino", | ||
@@ -21,3 +21,3 @@ "main": "logger.js", | ||
"dependencies": { | ||
"pino-http": "^5.1.0" | ||
"pino-http": "^5.3.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
@@ -105,2 +105,38 @@ # express-pino-logger [![Build Status](https://travis-ci.org/pinojs/express-pino-logger.svg)](https://travis-ci.org/pinojs/express-pino-logger) | ||
## Custom serializers | ||
The `req` object for logging is constructed by [pino-std-serializers](https://github.com/pinojs/pino-std-serializers) and custom properties added to the `req` in previous middleware are not automatically included. | ||
The original `req` is accessible in the custom serializer under `req.raw`. | ||
```js | ||
'use strict' | ||
var app = require('express')() | ||
var ExpressPinoLogger = require('express-pino-logger')() | ||
var pino = ExpressPinoLogger({ | ||
serializers: { | ||
req: (req) => ({ | ||
method: req.method, | ||
url: req.url, | ||
user: req.raw.user, | ||
}), | ||
}, | ||
}) | ||
// middleware that augments the req - must be added before the pino middleware | ||
app.use((req, res, next) => { | ||
req.user = 'testing'; | ||
next(); | ||
}) | ||
app.use(pino) | ||
... | ||
``` | ||
## API | ||
@@ -107,0 +143,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14211
163
Updatedpino-http@^5.3.0