Skip to content

Commit

Permalink
store profiling requests into the Stats too
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 22, 2019
1 parent d80989b commit 183ddad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/Compilation.js
Expand Up @@ -533,20 +533,6 @@ class Compilation extends Tapable {
}
let trace;
switch (type) {
case LogType.profile:
// 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(`[${name}] ${args[0]}`);
}
return;
case LogType.profileEnd:
// 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(`[${name}] ${args[0]}`);
}
return;
case LogType.warn:
case LogType.error:
case LogType.trace:
Expand All @@ -562,6 +548,13 @@ class Compilation extends Tapable {
trace
};
if (this.hooks.log.call(name, logEntry) === undefined) {
if (logEntry.type === LogType.profileEnd) {
// 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]}`);
}
}
if (logEntries === undefined) {
logEntries = this.logging.get(name);
if (logEntries === undefined) {
Expand All @@ -570,6 +563,13 @@ class Compilation extends Tapable {
}
}
logEntries.push(logEntry);
if (logEntry.type === LogType.profile) {
// 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]}`);
}
}
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions lib/Stats.js
Expand Up @@ -749,6 +749,8 @@ class Stats {
LogType.group,
LogType.groupEnd,
LogType.groupCollapsed,
LogType.profile,
LogType.profileEnd,
LogType.time,
LogType.clear
]);
Expand Down Expand Up @@ -1451,6 +1453,14 @@ class Stats {
case LogType.debug:
color = colors.normal;
break;
case LogType.profile:
color = colors.magenta;
prefix = "<p> ";
break;
case LogType.profileEnd:
color = colors.magenta;
prefix = "</p> ";
break;
case LogType.time:
color = colors.magenta;
prefix = "<t> ";
Expand Down

0 comments on commit 183ddad

Please sign in to comment.