Updated log function
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user