diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts new file mode 100644 index 0000000..4ef4693 --- /dev/null +++ b/src/utils/Logger.ts @@ -0,0 +1,21 @@ +import { colorCustom as c } from "./Functions/colors.js" +import { logTimeFormatter } from "./Functions/intlFormaters.js" + +const AllLogs = { + info: { m: "INFO", c: null }, + error: { m: "ERROR", c: "#ff6666" }, + warn: { m: "WARN", c: "#ffcc99" }, + debug: { m: "DEBUG", c: "#66ff66" } +} as const + +type LogType = keyof typeof AllLogs + +export function log(m: string, t: LogType = "info"): void { + const date = new Date() + const time = logTimeFormatter(date) + const logType = AllLogs[t].m + const logColor = AllLogs[t].c + + const message = `[${logType}] ${time} | ${m}` + console.log(logColor ? c(message, logColor) : message) +}