bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 187 forks source link

Conditional Whitelist for Response body? #285

Open ShakeebAftab opened 1 month ago

ShakeebAftab commented 1 month ago

My current logger looks something like this

export const expressRequestLogger = logger({
  transports: [
    new transports.File({
      filename: "logs/requests.log",
    }),
  ],
  meta: true,
  expressFormat: true,
  bodyBlacklist: ["password"],
  responseWhitelist: ["body"],
  statusLevels: true
});

I was wondering if there's a way to only allow body to be logged if the status code indicates an error?