Fix up logs view

This commit is contained in:
Andras Schmelczer 2024-12-20 17:35:30 +00:00
parent d77162ddf1
commit 818812aa2d
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 56 additions and 4 deletions

View file

@ -8,22 +8,25 @@ export enum LogLevel {
}
class LogLine {
public timestamp = new Date();
public constructor(public level: LogLevel, public message: string) {}
public toString(): string {
return `${this.formatLevel()}: ${this.message}`;
return `| ${this.formatLevel()} | ${this.timestamp.getHours()}:${this.timestamp.getMinutes()}:${this.timestamp.getSeconds()} | ${
this.message
}`;
}
private formatLevel(): string {
switch (this.level) {
case LogLevel.DEBUG:
return "DEBUG";
return " DEBUG";
case LogLevel.INFO:
return "INFO";
return " INFO";
case LogLevel.WARNING:
return "WARNING";
case LogLevel.ERROR:
return "ERROR";
return " ERROR";
default:
return "UNKNOWN";
}