I want to follow this example: https://www.npmjs.com/package/pino-http#use-as-express-middleware
but I also want to provide the logger()
call with the request object
Something like this:
const logger = require('pino-http')
const app = express()
app.use((req) => logger(req))
But it does not work (it crashes my server). Is it even possible? This logger
function does not actually accept any argument, but I have my custom function (which eventually returns pino-http logger instance) where I want to provide this argument.
New contributor
Tal Rofe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.