Skip to content

Commit 722ffa1

Browse files
committed
Revert "Enhance log viewer badge to display total and error log entries"
This reverts commit 72801b7.
1 parent 922f408 commit 722ffa1

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

src/extension.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,8 @@ function activateExtension(context: vscode.ExtensionContext, magentoRoot: string
7878
// Update the badge count
7979
const updateBadge = () => {
8080
const logFiles = logViewerProvider.getLogFilesWithoutUpdatingBadge(path.join(magentoRoot, 'var', 'log'));
81-
const totalEntries = logFiles.reduce((count, file) => {
82-
return count + (file.children?.reduce((childCount, child) => childCount + (child.children?.length || 0), 0) || 0);
83-
}, 0);
84-
const errorEntries = logFiles.reduce((count, file) => {
85-
return count + (file.children?.reduce((childCount, child) => {
86-
return childCount + (child.children?.filter(grandChild => grandChild.label.toLowerCase().includes('error')).length || 0);
87-
}, 0) || 0);
88-
}, 0);
89-
const entryText = totalEntries === 1 ? 'log entry' : 'log entries';
90-
treeView.badge = { value: totalEntries, tooltip: `${totalEntries} ${entryText} (${errorEntries} errors)` };
81+
const totalEntries = logFiles.reduce((count, file) => count + parseInt(file.description?.match(/\d+/)?.[0] || '0', 10), 0);
82+
treeView.badge = { value: totalEntries, tooltip: `${totalEntries} log entries` };
9183
};
9284

9385
logViewerProvider.onDidChangeTreeData(updateBadge);

src/logViewer.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogFile>, vsco
4848
public getLogFiles(dir: string): LogFile[] {
4949
if (this.pathExists(dir)) {
5050
const files = fs.readdirSync(dir);
51-
const logFiles = files.map(file => {
51+
this.updateBadge(files.length);
52+
return files.map(file => {
5253
const filePath = path.join(dir, file);
5354
const lineCount = this.getLineCount(filePath);
5455
const logFile = new LogFile(`${file} (${lineCount})`, vscode.TreeItemCollapsibleState.Collapsed, {
@@ -60,18 +61,8 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogFile>, vsco
6061
logFile.children = this.getLogFileLines(filePath);
6162
return logFile;
6263
});
63-
const totalEntries = logFiles.reduce((count, logFile) => {
64-
return count + (logFile.children?.reduce((childCount, child) => childCount + (child.children?.length || 0), 0) || 0);
65-
}, 0);
66-
const errorEntries = logFiles.reduce((count, logFile) => {
67-
return count + (logFile.children?.reduce((childCount, child) => {
68-
return childCount + (child.children?.filter(grandChild => grandChild.label.toLowerCase().includes('error')).length || 0);
69-
}, 0) || 0);
70-
}, 0);
71-
this.updateBadge(totalEntries, errorEntries);
72-
return logFiles;
7364
} else {
74-
this.updateBadge(0, 0);
65+
this.updateBadge(0);
7566
return [];
7667
}
7768
}
@@ -158,9 +149,8 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogFile>, vsco
158149
return true;
159150
}
160151

161-
private updateBadge(totalEntries: number = 0, errorEntries: number = 0): void {
162-
const entryText = totalEntries === 1 ? 'Magento Log-Entry' : 'Magento Log-Entries';
163-
this.statusBarItem.text = `${entryText}: ${totalEntries} (${errorEntries} errors)`;
152+
private updateBadge(count: number = 0): void {
153+
this.statusBarItem.text = `Magento Logs: ${count}`;
164154
}
165155

166156
dispose() {

0 commit comments

Comments
 (0)