tooot/src/utils/startup/log.ts

38 lines
797 B
TypeScript
Raw Normal View History

2021-01-07 19:13:09 +01:00
import chalk from 'chalk'
const ctx = new chalk.Instance({ level: 3 })
const log = (type: 'log' | 'warn' | 'error', func: string, message: string) => {
switch (type) {
case 'log':
console.log(
2023-01-08 16:59:35 +01:00
ctx.bgGrey.white.bold(' Start up ') +
2021-01-07 19:13:09 +01:00
' ' +
2023-01-08 16:59:35 +01:00
ctx.bgGrey.black(` ${func} `) +
2021-01-07 19:13:09 +01:00
' ' +
message
)
break
case 'warn':
console.warn(
ctx.bgYellow.white.bold(' Start up ') +
' ' +
ctx.bgYellowBright.black(` ${func} `) +
' ' +
message
)
break
case 'error':
console.error(
ctx.bgRed.white.bold(' Start up ') +
' ' +
ctx.bgRedBright.black(` ${func} `) +
' ' +
message
)
break
}
}
export default log