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

nestedKey now working properly

Open stychu opened this issue 2 years ago • 1 comments

I have this pinohttp logger setup with nestedKey. The log is not respecting req property to go inside the nestedKey if defined.

export const httpLoggerMiddleware = pinoHttp({
  redact: ['req.headers', 'res.headers'],
  msgPrefix: '[HTTP] ',
  nestedKey: 'logPayload',
});
  req: {
      "id": 4,
      "method": "GET",
      "url": "/asdsadad",
      "query": {
        "batch": "1",
      },
      "params": {},
      "headers": "[Redacted]",
      "remoteAddress": "::1",
      "remotePort": 52680
    }
    logPayload: {
      "res": {
        "statusCode": 200,
        "headers": "[Redacted]"
      },
      "responseTime": 15
    }

stychu avatar Nov 14 '23 12:11 stychu

This looks like a bug! Would you like to send a PR?

mcollina avatar Nov 16 '23 09:11 mcollina