mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-02-02 07:31:38 +01:00
Merge pull request #1064 from vector-im/bwindels/console-logging-expand-errors
ConsoleReporter: expand all parents of item that has an error
This commit is contained in:
commit
8c6c957ff3
@ -49,12 +49,26 @@ function filterValues(values: LogItemValues): LogItemValues | null {
|
|||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasChildWithError(item: LogItem): boolean {
|
||||||
|
if (item.error) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (item.children) {
|
||||||
|
for(const c of item.children) {
|
||||||
|
if (hasChildWithError(c)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function printToConsole(item: LogItem): void {
|
function printToConsole(item: LogItem): void {
|
||||||
const label = `${itemCaption(item)} (@${item.start}ms, duration: ${item.duration}ms)`;
|
const label = `${itemCaption(item)} (@${item.start}ms, duration: ${item.duration}ms)`;
|
||||||
const filteredValues = filterValues(item.values);
|
const filteredValues = filterValues(item.values);
|
||||||
const shouldGroup = item.children || filteredValues;
|
const shouldGroup = item.children || filteredValues;
|
||||||
if (shouldGroup) {
|
if (shouldGroup) {
|
||||||
if (item.error) {
|
if (hasChildWithError(item)) {
|
||||||
console.group(label);
|
console.group(label);
|
||||||
} else {
|
} else {
|
||||||
console.groupCollapsed(label);
|
console.groupCollapsed(label);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user