small fixes
This commit is contained in:
parent
7b31890a2f
commit
677ccd90ea
|
@ -101,6 +101,7 @@ const ErrorHelpers = require("./ErrorHelpers");
|
|||
* @typedef {Object} LogEntry
|
||||
* @property {string} type
|
||||
* @property {any[]} args
|
||||
* @property {number} time
|
||||
* @property {string[]=} trace
|
||||
*/
|
||||
|
||||
|
@ -521,6 +522,7 @@ class Compilation extends Tapable {
|
|||
if (!name) {
|
||||
throw new TypeError("Compilation.getLogger(name) called without a name");
|
||||
}
|
||||
/** @type {LogEntry[] | undefined} */
|
||||
let logEntries;
|
||||
return new Logger((type, args) => {
|
||||
if (typeof name === "function") {
|
||||
|
@ -541,6 +543,7 @@ class Compilation extends Tapable {
|
|||
.slice(3);
|
||||
break;
|
||||
}
|
||||
/** @type {LogEntry} */
|
||||
const logEntry = {
|
||||
time: Date.now(),
|
||||
type,
|
||||
|
@ -552,7 +555,7 @@ class Compilation extends Tapable {
|
|||
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
||||
if (typeof console.profileEnd === "function") {
|
||||
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
||||
console.profileEnd(`[${logEntry.name}] ${logEntry.args[0]}`);
|
||||
console.profileEnd(`[${name}] ${logEntry.args[0]}`);
|
||||
}
|
||||
}
|
||||
if (logEntries === undefined) {
|
||||
|
@ -567,7 +570,7 @@ class Compilation extends Tapable {
|
|||
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
||||
if (typeof console.profile === "function") {
|
||||
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
||||
console.profile(`[${logEntry.name}] ${logEntry.args[0]}`);
|
||||
console.profile(`[${name}] ${logEntry.args[0]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class Compiler extends Tapable {
|
|||
watchClose: new SyncHook([]),
|
||||
|
||||
/** @type {SyncBailHook<string, string, any[]>} */
|
||||
log: new SyncBailHook(["origin", "type", "args"]),
|
||||
infrastructurelog: new SyncBailHook(["origin", "type", "args"]),
|
||||
|
||||
// TODO the following hooks are weirdly located here
|
||||
// TODO move them for webpack 5
|
||||
|
@ -221,7 +221,7 @@ class Compiler extends Tapable {
|
|||
);
|
||||
}
|
||||
}
|
||||
if (this.hooks.log.call(name, type, args) === undefined) {
|
||||
if (this.hooks.infrastructurelog.call(name, type, args) === undefined) {
|
||||
if (this.infrastructureLogger !== undefined) {
|
||||
this.infrastructureLogger(name, type, args);
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ class NormalModule extends Module {
|
|||
return compilation.getLogger(() =>
|
||||
[currentLoader && currentLoader.loader, name, this.identifier()]
|
||||
.filter(Boolean)
|
||||
.join(" ")
|
||||
.join("|")
|
||||
);
|
||||
},
|
||||
// TODO remove in webpack 5
|
||||
|
|
21
lib/Stats.js
21
lib/Stats.js
|
@ -776,8 +776,11 @@ class Stats {
|
|||
if (collapseCounter > 0) collapseCounter++;
|
||||
return collapseCounter === 0;
|
||||
case LogType.groupEnd:
|
||||
collapseCounter--;
|
||||
return collapseCounter === 0;
|
||||
if (collapseCounter > 0) {
|
||||
collapseCounter--;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return collapseCounter === 0;
|
||||
}
|
||||
|
@ -803,9 +806,17 @@ class Stats {
|
|||
trace: showLoggingTrace && entry.trace ? entry.trace : undefined
|
||||
};
|
||||
});
|
||||
obj.logging[
|
||||
identifierUtils.makePathsRelative(context, origin, compilation.cache)
|
||||
] = {
|
||||
let name = identifierUtils
|
||||
.makePathsRelative(context, origin, compilation.cache)
|
||||
.replace(/\|/g, " ");
|
||||
if (name in obj.logging) {
|
||||
let i = 1;
|
||||
while (`${name}#${i}` in obj.logging) {
|
||||
i++;
|
||||
}
|
||||
name = `${name}#${i}`;
|
||||
}
|
||||
obj.logging[name] = {
|
||||
entries: processedLogEntries,
|
||||
filteredEntries: logEntries.length - processedLogEntries.length,
|
||||
debug: debugMode
|
||||
|
|
|
@ -15,7 +15,7 @@ const { LogType } = require("./Logger");
|
|||
|
||||
/**
|
||||
* @typedef {Object} LoggerOptions
|
||||
* @property {false|true|"error"|"warn"|"info"|"log"|"verbose"} options.level loglevel
|
||||
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} options.level loglevel
|
||||
* @property {FilterTypes|boolean} options.debug filter for debug logging
|
||||
*/
|
||||
|
||||
|
|
|
@ -1247,7 +1247,7 @@ Entrypoint <CLR=BOLD>main</CLR> = <CLR=32,BOLD>main.js</CLR>
|
|||
<CLR=BOLD>LOG from MyPlugin</CLR>
|
||||
<i> <CLR=32,BOLD>Plugin is now active</CLR>
|
||||
<+> <CLR=36,BOLD>Nested</CLR>
|
||||
+ 2 hidden lines
|
||||
+ 3 hidden lines
|
||||
|
||||
<CLR=31,BOLD>DEBUG </CLR><CLR=BOLD>LOG from node_modules/custom-loader/index.js node_modules/custom-loader/index.js!index.js</CLR>
|
||||
<e> <CLR=31,BOLD>An error</CLR>
|
||||
|
|
Loading…
Reference in New Issue