feat: 🔊 Logger update

This commit is contained in:
DitFranXX
2021-05-26 13:07:33 +09:00
parent a8759b3a4e
commit 860e2c8c7b
3 changed files with 35 additions and 6 deletions
+25
View File
@@ -0,0 +1,25 @@
import { isAsphyxiaDebugMode } from ".";
export default class Logger {
public category: string | null;
public constructor(category?: string) {
this.category = (category == null) ? null : `[${category}]`
}
public error(...args: any[]) {
this.argsHandler(console.error, ...args)
}
public debugError(...args: any[]) {
if (isAsphyxiaDebugMode()) {
this.argsHandler(console.warn, ...args)
}
}
private argsHandler(target: Function, ...args: any[]) {
if (this.category == null) {
target(...args)
} else {
target(this.category, ...args)
}
}
}