node_modules/winston/lib/winston/create-logger.js
/**
   * Create the log level methods for the derived logger.
   * @returns {undefined}
   * @private
   */
Create the log level methods for the derived logger.
@returns {undefined}
@private
Create the log level methods for the derived logger . @returns { undefined } @private
_setupLevels() {
    Object.keys(this.levels).forEach(level => {
      debug('Define prototype method for "%s"', level);
      if (level === 'log') {
        console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');
        return;
      }
      this[level] = (...args) => {
        if (args.length === 1) {
          const [msg] = args;
          const info = msg && msg.message && msg || { message: msg };
          info.level = info[LEVEL] = level;
          this.write(info);
          return this;
        }
        return this.log(level, ...args);
      };
    });
  }
_setupLevels ( ) { Object . keys ( this . levels ) . forEach ( level => { debug ( 'Define prototype method for "%s"' , level ) ; if ( level === 'log' ) { console . warn ( 'Level "log" not defined: conflicts with the method "log". Use a different level name.' ) ; return ; } this [ level ] = ( ... args ) => { if ( args . length === 1 ) { const [ msg ] = args ; const info = msg && msg . message && msg || { message : msg } ; info . level = info [ LEVEL ] = level ; this . write ( info ) ; return this ; } return this . log ( level , ... args ) ; } ; } ) ; }
Create the log level methods for the derived logger.
Create the log level methods for the derived logger .
// eslint-disable-next-line no-console // Define prototype methods for each log level // e.g. logger.log('info', msg) <––> logger.info(msg) // Optimize the hot-path which is the single object. // Otherwise build argument list which could potentially conform to // either: // . v3 API: log(obj) // 2. v1/v2 API: log(level, msg, ... [string interpolate], [{metadata}], [callback])