To debug my router, I’d like to console log all request details.
The example from:
https://docs.layer0.co/guides/debugging#section_cloud
.get('/p/:productId', ({ cache }) => {
proxy('origin', {
// The presence of transformRequest and transformResponse ensure that proxying is done in serverless, not at the edge.
transformRequest: (req) => {
console.log('Request ID', req.headers['x-request-id'])
// Log request properties that you want to troubleshoot.
},
transformResponse: (res, req) => {
console.log('Response for request ID', req.headers['x-request-id'], 'status code', res.statusCode)
// Log response properties that you want to troubleshoot.
}
})
})
Looks powerful and close to what I need, but I’d like to avoid having to add the console.log to every route.
How can I log the request object without adding console.logs to every route?