bithavoc / express-winston

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

Expose meta to Template #191

Closed jd-carroll closed 1 year ago

jd-carroll commented 5 years ago

The meta object can contain valuable information for the printed log format (such as the authenticated user), but it not used in the template process. The template functions should each be updated to the following:

exports.errorLogger = function errorLogger(options) {
  // ...
  options.winstonInstance.log({
    level,
    message: getTemplate(options.msg, {err: err, req: req, res: res, meta: exceptionMeta}),
    meta: exceptionMeta
  });
  // ...
};

exports.logger = function logger(options) {
  // ...
  var msg = template({req: req, res: _.assign({}, res, coloredRes), meta});
  // ...
};