You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
636 B

7 months ago
import log from 'loglevel';
import chalk from './chalk';
import prefix from 'loglevel-plugin-prefix';
const colors: any = {
TRACE: chalk.magenta,
DEBUG: chalk.cyan,
INFO: chalk.blue,
WARN: chalk.yellow,
ERROR: chalk.red,
};
prefix.reg(log);
log.enableAll();
prefix.apply(log, {
format(level, name, timestamp) {
return `${chalk.gray(`[${timestamp}]`)} ${colors[level.toUpperCase()](level)} ${chalk.green(
`${name}:`
)}`;
},
});
// prefix.apply(log.getLogger('critical'), {
// format(level, name, timestamp) {
// return chalk.red.bold(`[${timestamp}] ${level} ${name}:`);
// },
// });
export { log };