• File: volume.js
  • Full Path: /var/www/nodejs/daily_store_reports_nodejs/node_modules/logform/examples/volume.js
  • Date Modified: 02/04/2023 9:31 PM
  • File size: 705 bytes
  • MIME-type: text/plain
  • Charset: utf-8
const { format } = require('../');

const volume = format((info, opts) => {
  if (opts.yell) {
    info.message = info.message.toUpperCase();
  } else if (opts.whisper) {
    info.message = info.message.toLowerCase();
  }

  return info;
});

// `volume` is now a function that returns instances of the format.
const scream = volume({ yell: true });
console.dir(scream.transform({
  level: 'info',
  message: `sorry for making you YELL in your head!`
}, scream.options));

// `volume` can be used multiple times to create different formats.
const whisper = volume({ whisper: true });
console.dir(whisper.transform({
  level: 'info',
  message: `WHY ARE THEY MAKING US YELL SO MUCH!`
}, whisper.options));