WXL
3 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/logging/Logger.js
@@ -30,24 +30,31 @@
module.exports.LogType = LogType;
/** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */
/** @typedef {Map<string | undefined, [number, number]>} TimersMap */
const LOG_SYMBOL = Symbol("webpack logger raw log method");
const TIMERS_SYMBOL = Symbol("webpack logger times");
const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
/** @typedef {EXPECTED_ANY[]} Args */
/** @typedef {(type: LogTypeEnum, args?: Args) => void} LogFn */
/** @typedef {(name: string | (() => string)) => WebpackLogger} GetChildLogger */
class WebpackLogger {
   /**
    * @param {(type: LogTypeEnum, args?: Args) => void} log log function
    * @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
    * Creates an instance of WebpackLogger.
    * @param {LogFn} log log function
    * @param {GetChildLogger} getChildLogger function to create child logger
    */
   constructor(log, getChildLogger) {
      /** @type {LogFn} */
      this[LOG_SYMBOL] = log;
      /** @type {GetChildLogger} */
      this.getChildLogger = getChildLogger;
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   error(...args) {
@@ -55,6 +62,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   warn(...args) {
@@ -62,6 +70,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   info(...args) {
@@ -69,6 +78,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   log(...args) {
@@ -76,6 +86,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   debug(...args) {
@@ -83,11 +94,12 @@
   }
   /**
    * @param {EXPECTED_ANY} assertion assertion
    * Processes the provided condition.
    * @param {boolean=} condition condition
    * @param {Args} args args
    */
   assert(assertion, ...args) {
      if (!assertion) {
   assert(condition, ...args) {
      if (!condition) {
         this[LOG_SYMBOL](LogType.error, args);
      }
   }
@@ -101,6 +113,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   status(...args) {
@@ -108,6 +121,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   group(...args) {
@@ -115,6 +129,7 @@
   }
   /**
    * Processes the provided arg.
    * @param {Args} args args
    */
   groupCollapsed(...args) {
@@ -126,6 +141,7 @@
   }
   /**
    * Processes the provided label.
    * @param {string=} label label
    */
   profile(label) {
@@ -133,6 +149,7 @@
   }
   /**
    * Processes the provided label.
    * @param {string=} label label
    */
   profileEnd(label) {
@@ -140,15 +157,17 @@
   }
   /**
    * Processes the provided label.
    * @param {string} label label
    */
   time(label) {
      /** @type {Map<string | undefined, [number, number]>} */
      /** @type {TimersMap} */
      this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
      this[TIMERS_SYMBOL].set(label, process.hrtime());
   }
   /**
    * Processes the provided label.
    * @param {string=} label label
    */
   timeLog(label) {
@@ -161,6 +180,7 @@
   }
   /**
    * Processes the provided label.
    * @param {string=} label label
    */
   timeEnd(label) {
@@ -169,12 +189,13 @@
         throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
      }
      const time = process.hrtime(prev);
      /** @type {Map<string | undefined, [number, number]>} */
      /** @type {TimersMap} */
      (this[TIMERS_SYMBOL]).delete(label);
      this[LOG_SYMBOL](LogType.time, [label, ...time]);
   }
   /**
    * Processes the provided label.
    * @param {string=} label label
    */
   timeAggregate(label) {
@@ -185,9 +206,9 @@
         );
      }
      const time = process.hrtime(prev);
      /** @type {Map<string | undefined, [number, number]>} */
      /** @type {TimersMap} */
      (this[TIMERS_SYMBOL]).delete(label);
      /** @type {Map<string | undefined, [number, number]>} */
      /** @type {TimersMap} */
      this[TIMERS_AGGREGATES_SYMBOL] =
         this[TIMERS_AGGREGATES_SYMBOL] || new Map();
      const current = this[TIMERS_AGGREGATES_SYMBOL].get(label);
@@ -204,6 +225,7 @@
   }
   /**
    * Time aggregate end.
    * @param {string=} label label
    */
   timeAggregateEnd(label) {