pino-noir icon indicating copy to clipboard operation
pino-noir copied to clipboard

Add example (or even test case)?

Open jsumners opened this issue 6 years ago • 0 comments

I had to write the following test application to determine if my desired use case would work. I couldn't find it in the documentation or tests. Specifically, I needed to know if I could specify serializers in addition to the ones returned by pino-noir. So I'm wondering if we think this should be added to the documentation at the least:

'use strict'

const app = require('express')()
const pino = require('pino')
const noir = require('pino-noir')(['req.headers.host'])
const serializers = {
  err: pino.stdSerializers.err
}
const logger = require('express-pino-logger')({
  level: 'debug',
  serializers: Object.assign({}, serializers, noir)
})

app.use(logger)

app.get('/', (req, reply) => {
  req.log.error(Error('this is a test'))
  reply.send('hello world')
})

app.listen(3000)

Also, holy 🐄!, the logged express request object is huge.

jsumners avatar Nov 21 '17 14:11 jsumners