pino-http
pino-http copied to clipboard
dynamic serializer swapping
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
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.
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