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:
Bruno Windels 2023-03-29 00:31:24 +02:00 committed by GitHub
commit 8c6c957ff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,12 +49,26 @@ function filterValues(values: LogItemValues): LogItemValues | 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 {
const label = `${itemCaption(item)} (@${item.start}ms, duration: ${item.duration}ms)`;
const filteredValues = filterValues(item.values);
const shouldGroup = item.children || filteredValues;
if (shouldGroup) {
if (item.error) {
if (hasChildWithError(item)) {
console.group(label);
} else {
console.groupCollapsed(label);