• File: printf.js
  • Full Path: /var/www/nodejs/daily_store_reports_nodejs/node_modules/logform/printf.js
  • Date Modified: 02/04/2023 9:31 PM
  • File size: 515 bytes
  • MIME-type: text/plain
  • Charset: utf-8
'use strict';

const { MESSAGE } = require('triple-beam');

class Printf {
  constructor(templateFn) {
    this.template = templateFn;
  }

  transform(info) {
    info[MESSAGE] = this.template(info);
    return info;
  }
}

/*
 * function printf (templateFn)
 * Returns a new instance of the printf Format that creates an
 * intermediate prototype to store the template string-based formatter
 * function.
 */
module.exports = opts => new Printf(opts);

module.exports.Printf
  = module.exports.Format
  = Printf;