Added logger function
This commit is contained in:
21
src/utils/Logger.ts
Normal file
21
src/utils/Logger.ts
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user