label.js 469 B

12345678910111213141516171819
  1. 'use strict';
  2. const format = require('./format');
  3. /*
  4. * function label (info)
  5. * Returns a new instance of the label Format which adds the specified
  6. * `opts.label` before the message. This was previously exposed as
  7. * { label: 'my label' } to transports in `winston < 3.0.0`.
  8. */
  9. module.exports = format((info, opts) => {
  10. if (opts.message) {
  11. info.message = `[${opts.label}] ${info.message}`;
  12. return info;
  13. }
  14. info.label = opts.label;
  15. return info;
  16. });