push
This commit is contained in:
26
lib/util/log.ts
Normal file
26
lib/util/log.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user