| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2019-07-24 16:51:04 +08:00
										 |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const LogType = Object.freeze({ | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | 	error: /** @type {"error"} */ ("error"), // message, c style arguments
 | 
					
						
							|  |  |  | 	warn: /** @type {"warn"} */ ("warn"), // message, c style arguments
 | 
					
						
							|  |  |  | 	info: /** @type {"info"} */ ("info"), // message, c style arguments
 | 
					
						
							|  |  |  | 	log: /** @type {"log"} */ ("log"), // message, c style arguments
 | 
					
						
							|  |  |  | 	debug: /** @type {"debug"} */ ("debug"), // message, c style arguments
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | 	trace: /** @type {"trace"} */ ("trace"), // no arguments
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | 	group: /** @type {"group"} */ ("group"), // [label]
 | 
					
						
							|  |  |  | 	groupCollapsed: /** @type {"groupCollapsed"} */ ("groupCollapsed"), // [label]
 | 
					
						
							|  |  |  | 	groupEnd: /** @type {"groupEnd"} */ ("groupEnd"), // [label]
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | 	profile: /** @type {"profile"} */ ("profile"), // [profileName]
 | 
					
						
							|  |  |  | 	profileEnd: /** @type {"profileEnd"} */ ("profileEnd"), // [profileName]
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | 	time: /** @type {"time"} */ ("time"), // name, time as [seconds, nanoseconds]
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | 	clear: /** @type {"clear"} */ ("clear"), // no arguments
 | 
					
						
							|  |  |  | 	status: /** @type {"status"} */ ("status") // message, arguments
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exports.LogType = LogType; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-07 17:55:31 +08:00
										 |  |  | /** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */ | 
					
						
							| 
									
										
										
										
											2019-07-19 18:31:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | const LOG_SYMBOL = Symbol("webpack logger raw log method"); | 
					
						
							|  |  |  | const TIMERS_SYMBOL = Symbol("webpack logger times"); | 
					
						
							| 
									
										
										
										
											2020-01-30 18:34:33 +08:00
										 |  |  | const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times"); | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class WebpackLogger { | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2019-09-10 15:15:20 +08:00
										 |  |  | 	 * @param {function(LogTypeEnum, any[]=): void} log log function | 
					
						
							| 
									
										
										
										
											2019-11-05 23:47:45 +08:00
										 |  |  | 	 * @param {function(string | function(): string): WebpackLogger} getChildLogger function to create child logger | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2019-11-05 23:47:45 +08:00
										 |  |  | 	constructor(log, getChildLogger) { | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 		this[LOG_SYMBOL] = log; | 
					
						
							| 
									
										
										
										
											2019-11-05 23:47:45 +08:00
										 |  |  | 		this.getChildLogger = getChildLogger; | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	error(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.error, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	warn(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.warn, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	info(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.info, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	log(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.log, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	debug(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.debug, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	assert(assertion, ...args) { | 
					
						
							|  |  |  | 		if (!assertion) { | 
					
						
							|  |  |  | 			this[LOG_SYMBOL](LogType.error, args); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	trace() { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.trace, ["Trace"]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	clear() { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.clear); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-28 01:48:10 +08:00
										 |  |  | 	status(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.status, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 	group(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.group, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	groupCollapsed(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.groupCollapsed, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	groupEnd(...args) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.groupEnd, args); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	profile(label) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.profile, [label]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	profileEnd(label) { | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.profileEnd, [label]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	time(label) { | 
					
						
							|  |  |  | 		this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map(); | 
					
						
							|  |  |  | 		this[TIMERS_SYMBOL].set(label, process.hrtime()); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	timeLog(label) { | 
					
						
							|  |  |  | 		const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label); | 
					
						
							|  |  |  | 		if (!prev) { | 
					
						
							|  |  |  | 			throw new Error(`No such label '${label}' for WebpackLogger.timeLog()`); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const time = process.hrtime(prev); | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.time, [label, ...time]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	timeEnd(label) { | 
					
						
							|  |  |  | 		const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label); | 
					
						
							|  |  |  | 		if (!prev) { | 
					
						
							|  |  |  | 			throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const time = process.hrtime(prev); | 
					
						
							|  |  |  | 		this[TIMERS_SYMBOL].delete(label); | 
					
						
							|  |  |  | 		this[LOG_SYMBOL](LogType.time, [label, ...time]); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-01-30 18:34:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	timeAggregate(label) { | 
					
						
							|  |  |  | 		const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label); | 
					
						
							|  |  |  | 		if (!prev) { | 
					
						
							|  |  |  | 			throw new Error( | 
					
						
							|  |  |  | 				`No such label '${label}' for WebpackLogger.timeAggregate()` | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const time = process.hrtime(prev); | 
					
						
							|  |  |  | 		this[TIMERS_SYMBOL].delete(label); | 
					
						
							|  |  |  | 		this[TIMERS_AGGREGATES_SYMBOL] = | 
					
						
							|  |  |  | 			this[TIMERS_AGGREGATES_SYMBOL] || new Map(); | 
					
						
							|  |  |  | 		const current = this[TIMERS_AGGREGATES_SYMBOL].get(label); | 
					
						
							|  |  |  | 		if (current !== undefined) { | 
					
						
							|  |  |  | 			if (time[1] + current[1] > 1e9) { | 
					
						
							|  |  |  | 				time[0] += current[0] + 1; | 
					
						
							|  |  |  | 				time[1] = time[1] - 1e9 + current[1]; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				time[0] += current[0]; | 
					
						
							|  |  |  | 				time[1] += current[1]; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		this[TIMERS_AGGREGATES_SYMBOL].set(label, time); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	timeAggregateEnd(label) { | 
					
						
							|  |  |  | 		if (this[TIMERS_AGGREGATES_SYMBOL] === undefined) return; | 
					
						
							|  |  |  | 		const time = this[TIMERS_AGGREGATES_SYMBOL].get(label); | 
					
						
							|  |  |  | 		if (time === undefined) return; | 
					
						
							| 
									
										
										
										
											2021-10-05 23:25:33 +08:00
										 |  |  | 		this[TIMERS_AGGREGATES_SYMBOL].delete(label); | 
					
						
							| 
									
										
										
										
											2020-01-30 18:34:33 +08:00
										 |  |  | 		this[LOG_SYMBOL](LogType.time, [label, ...time]); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exports.Logger = WebpackLogger; |