Added logger function

This commit is contained in:
2024-11-14 17:25:26 +01:00
parent a9b1d5ba67
commit 0f583206b3

21
src/utils/Logger.ts Normal file
View File

@@ -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)
}