import chalk from "chalk" import { logTimeFormatter } from "./Functions/intlFormaters.js" const colors = { red: "#f38ba8", lavender: "#b4befe", green: "#a6e3a1", pink: "#f5c2e7" } type Colors = keyof typeof colors 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 type CustomColorProps = { type: "preset" color: Colors } | { type: "custom" color: string } export function log(m: string, t: LogType, c?: CustomColorProps): void { const date = new Date() const time = logTimeFormatter(date) const logType = AllLogs[t].m const logColor = AllLogs[t].c const message = `[${logType}] ${time} | ${m}` if (!c) { if (t === "info") { console.log(message) return } console.log(cc(message, logColor!)) return } if (c.type === "preset") { const color = colors[c.color] console.log(cc(message, color)) } else { console.log(cc(message, c.color)) } } function cc(text: string, color: string) { return chalk.hex(color)(text) }