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

dynamic serializer swapping

Open davidmarkclements opened this issue 8 years ago • 2 comments

Consider a situation where we log every time for a certain route, and we're not interested in seeing the request completed for this route (in particularly I'm thinking about transmitting logs from the browser to the server, say to a /logs route)

I'd like to be able to do

var pinoHttp = require('pino-http')({ignore: ['/logs']}) 

and maybe even

var pinoHttp = require('pino-http')({ignore: [{method: 'POST', url: '/logs'}]}) 

It would also be good to be able to do

var pinoHttp = require('pino-http')
pinoHttp.ignore('/logs') // or pinoHttp.ignore({method: 'POST', url: '/logs'}]})

This wouldn't remove the req.log method, it would just avoid emitting the "request completed" log for a route

davidmarkclements avatar Oct 25 '17 15:10 davidmarkclements

I do not think it's a great idea. We would need to a router, and then parametric routes, and then wildcards, and then this would become very slow. Let's log everything.

mcollina avatar Oct 26 '17 07:10 mcollina

another approach... if we could dynamically swap out the req serializer the log message from the browser could be injected into the req object instead on request completed to a /logs endpoint

davidmarkclements avatar Oct 26 '17 20:10 davidmarkclements