import chalk from "chalk" import { logTimeFormatter } from "./Functions/intlFormaters" const colors = { red: "#f38ba8", lavender: "#b4befe", green: "#a6e3a1", pink: "#f5c2e7" } type Colors = keyof typeof colors const AllLogs = { info: { m: "INFO", c: "#a6e3a1" }, warn: { m: "WARN", c: "#fab387" }, error: { m: "ERROR", c: "#f38ba8" }, critical: { m: "CRITICAL", c: "#ff3d3d" }, debug: { m: "DEBUG", c: "#f9e2af" } } as const type LogType = keyof typeof AllLogs type CustomColorProps = { type: "preset" color: Colors } | { type: "custom" color: string } const date = new Date() const time = logTimeFormatter(date) function info(msg: any) { const message = `${time} - [${AllLogs.info.m}] | ${msg}` console.log(cc(message, AllLogs.info.c)) } function warn(msg: any) { const message = `${time} - [${AllLogs.warn.m}] | ${msg}` console.log(cc(message, AllLogs.warn.c)) } function error(msg: any) { const message = `${time} - [${AllLogs.error.m}] | ${msg}` console.error(cc(message, AllLogs.error.c)) } function critical(msg: any) { const message = `${time} - [${AllLogs.critical.m}] | ${msg}` console.error(cc(message, AllLogs.critical.c)) } function custom(msg: any, type: LogType, c: CustomColorProps) { const log = AllLogs[type].m const message = `${time} - [${log}] | ${msg}` 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) } const log = { info, warn, error, critical, custom } export { cc, log }