Skip to content

Commit 919b326

Browse files
committed
feat: add color coding for log levels in log viewer
1 parent b12755e commit 919b326

File tree

3 files changed

+75
-6
lines changed

3 files changed

+75
-6
lines changed

package.json

+47
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,53 @@
7474
}
7575
}
7676
},
77+
"colors": [
78+
{
79+
"id": "magentoLogViewer.errorColor",
80+
"description": "Color for error log entries",
81+
"defaults": {
82+
"dark": "#f14c4c",
83+
"light": "#cd3131",
84+
"highContrast": "#ff0000"
85+
}
86+
},
87+
{
88+
"id": "magentoLogViewer.warningColor",
89+
"description": "Color for warning log entries",
90+
"defaults": {
91+
"dark": "#cca700",
92+
"light": "#ff8f00",
93+
"highContrast": "#ffd700"
94+
}
95+
},
96+
{
97+
"id": "magentoLogViewer.debugColor",
98+
"description": "Color for debug log entries",
99+
"defaults": {
100+
"dark": "#ffeb3b",
101+
"light": "#ffd700",
102+
"highContrast": "#ffff00"
103+
}
104+
},
105+
{
106+
"id": "magentoLogViewer.infoColor",
107+
"description": "Color for info log entries",
108+
"defaults": {
109+
"dark": "#3794ff",
110+
"light": "#0078d4",
111+
"highContrast": "#0099ff"
112+
}
113+
},
114+
{
115+
"id": "magentoLogViewer.criticalColor",
116+
"description": "Color for critical log entries",
117+
"defaults": {
118+
"dark": "#ff1493",
119+
"light": "#ff1493",
120+
"highContrast": "#ff69b4"
121+
}
122+
}
123+
],
77124
"viewsContainers": {
78125
"activitybar": [
79126
{

src/helpers.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,19 @@ export function getLineCount(filePath: string): number {
215215

216216
// Returns the appropriate icon for the given log level.
217217
export function getIconForLogLevel(level: string): vscode.ThemeIcon {
218-
switch (level) {
219-
case 'ERROR': return new vscode.ThemeIcon('error');
220-
case 'WARN': return new vscode.ThemeIcon('warning');
221-
case 'DEBUG': return new vscode.ThemeIcon('debug');
222-
case 'INFO': return new vscode.ThemeIcon('info');
223-
default: return new vscode.ThemeIcon('circle-outline');
218+
switch (level.toUpperCase()) {
219+
case 'CRITICAL':
220+
return new vscode.ThemeIcon('error', new vscode.ThemeColor('magentoLogViewer.criticalColor'));
221+
case 'ERROR':
222+
return new vscode.ThemeIcon('error', new vscode.ThemeColor('magentoLogViewer.errorColor'));
223+
case 'WARN':
224+
return new vscode.ThemeIcon('warning', new vscode.ThemeColor('magentoLogViewer.warningColor'));
225+
case 'DEBUG':
226+
return new vscode.ThemeIcon('debug', new vscode.ThemeColor('magentoLogViewer.debugColor'));
227+
case 'INFO':
228+
return new vscode.ThemeIcon('info', new vscode.ThemeColor('magentoLogViewer.infoColor'));
229+
default:
230+
return new vscode.ThemeIcon('circle-outline');
224231
}
225232
}
226233

src/logViewer.ts

+15
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,21 @@ export class LogItem extends vscode.TreeItem {
327327
super(label, collapsibleState as vscode.TreeItemCollapsibleState);
328328
this.description = this.label.match(/\(\d+\)/)?.[0] || '';
329329
this.label = this.label.replace(/\(\d+\)/, '').trim();
330+
331+
// Füge Farben basierend auf Log-Level hinzu
332+
if (this.label.includes('ERROR')) {
333+
this.tooltip = 'Error Message';
334+
this.resourceUri = vscode.Uri.parse('error');
335+
} else if (this.label.includes('WARN')) {
336+
this.tooltip = 'Warning Message';
337+
this.resourceUri = vscode.Uri.parse('warning');
338+
} else if (this.label.includes('DEBUG')) {
339+
this.tooltip = 'Debug Message';
340+
this.resourceUri = vscode.Uri.parse('debug');
341+
} else if (this.label.includes('INFO')) {
342+
this.tooltip = 'Info Message';
343+
this.resourceUri = vscode.Uri.parse('info');
344+
}
330345
}
331346

332347
contextValue = 'logItem';

0 commit comments

Comments
 (0)