const levelMap = { "ALL": 0, "TRACE": 1, "DEBUG": 2, "INFO": 3, "WARN": 4, "ERROR": 5, "FATAL": 6, "OFF": 7,} as { [key: string]: number };
const DEFAULT_LEVEL = "INFO";
export class Logger { private static printer = console;
level = levelMap[DEFAULT_LEVEL];
constructor(opt = { level: DEFAULT_LEVEL }) { let { level } = opt;
if (typeof level === "string") { level = level.toUpperCase(); }
if (levelMap[level] > -1) { this.level = levelMap[level]; } }
private print(type: string, info: Array<any>) { if (levelMap[type] >= this.level) { Logger.printer.log.apply(Logger.printer, [`[Fen][${type}]\t`, ...info]); } }
changeLevel(level: string = DEFAULT_LEVEL) { this.level = levelMap[level] || 0; }
trace(...info: any[]) { this.print("TRACE", info); }
debug(...info: any[]) { this.print("DEBUG", info); }
info(...info: any[]) { this.print("INFO", info); }
warn(...info: any[]) { this.print("WARN", info); }
error(...info: any[]) { this.print("ERROR", info); }
fatal(...info: any[]) { this.print("FATAL", info); }}