express-winston icon indicating copy to clipboard operation
express-winston copied to clipboard

Expose meta to Template

Open jd-carroll opened this issue 7 years ago • 0 comments

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});
  // ...
};

jd-carroll avatar Sep 19 '18 20:09 jd-carroll