Updated log function

This commit is contained in:
2025-06-01 20:30:58 +02:00
parent dd12b86092
commit d165ad15c2
19 changed files with 90 additions and 65 deletions

View File

@@ -28,17 +28,32 @@ type CustomColorProps = {
color: string
}
export function log(m: any, t: LogType, c?: CustomColorProps): void {
const date = new Date()
const time = logTimeFormatter(date)
const logType = AllLogs[t].m
const logColor = AllLogs[t].c
const date = new Date()
const time = logTimeFormatter(date)
const message = `${time} - [${logType}] | ${m}`
if (!c) {
console.log(cc(message, logColor))
return
}
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]
@@ -51,3 +66,13 @@ export function log(m: any, t: LogType, c?: CustomColorProps): void {
function cc(text: string, color: string) {
return chalk.hex(color)(text)
}
const log = {
info,
warn,
error,
critical,
custom
}
export { cc, log }