mirror of
https://github.com/cloudmaker97/TikTok-mGBA-Emulator.git
synced 2025-12-06 07:58:38 +00:00
51 lines
No EOL
1.5 KiB
TypeScript
51 lines
No EOL
1.5 KiB
TypeScript
export enum LogLevel {
|
|
INFO = 1,
|
|
WARNING = 2,
|
|
ERROR = 3,
|
|
DEBUG = 4
|
|
}
|
|
|
|
export class Logger {
|
|
/**
|
|
* Log a message to the console
|
|
* @param message {string}
|
|
* @param category {string}
|
|
* @param level {LogLevel}
|
|
*/
|
|
static logMessage(message: string, category: string = "App", level: LogLevel = LogLevel.INFO) {
|
|
console.log(`[${this.logLevelToString(level)}] [${category}] ${message}`);
|
|
}
|
|
|
|
/**
|
|
* Log a message to the console with additional data
|
|
* @param message {string}
|
|
* @param data {any}
|
|
* @param category {string}
|
|
* @param level {LogLevel}
|
|
*/
|
|
static logDebug(message: string, data: any, category: string = "App", level: LogLevel = LogLevel.INFO) {
|
|
this.logMessage(message, category, level);
|
|
console.log(data);
|
|
console.log("--------------------------------------------------");
|
|
}
|
|
|
|
/**
|
|
* Get the string representation of a log level
|
|
* @param level {LogLevel} The log level to convert to a string
|
|
* @returns The string representation of the log level
|
|
*/
|
|
static logLevelToString(level: LogLevel): string {
|
|
switch (level) {
|
|
case LogLevel.INFO:
|
|
return "INFO";
|
|
case LogLevel.WARNING:
|
|
return "WARNING";
|
|
case LogLevel.ERROR:
|
|
return "ERROR";
|
|
case LogLevel.DEBUG:
|
|
return "DEBUG";
|
|
default:
|
|
return "UNKNOWN";
|
|
}
|
|
}
|
|
} |