add logging prefix and colors

This commit is contained in:
KGT1 2021-01-18 07:15:12 +01:00
parent c717eb152c
commit 2e48f43b72

View File

@ -10,9 +10,34 @@ try {
handleChannelMessage handleChannelMessage
} = require("./messagehandler"); } = require("./messagehandler");
const log = require("loglevel"); const log = require("loglevel");
const prefix = require('loglevel-plugin-prefix');
const chalk = require('chalk');
const colors = {
TRACE: chalk.magenta,
DEBUG: chalk.cyan,
INFO: chalk.blue,
WARN: chalk.yellow,
ERROR: chalk.red,
};
log.setLevel(CONFIG["log-level"]); log.setLevel(CONFIG["log-level"]);
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}:`);
},
});
jellyfinClientManager.init(); jellyfinClientManager.init();
// TODO Error Checking as the apiclients is inefficent // TODO Error Checking as the apiclients is inefficent
jellyfinClientManager.getJellyfinClient().authenticateUserByName(CONFIG["jellyfin-username"], CONFIG["jellyfin-password"]).then((response) => { jellyfinClientManager.getJellyfinClient().authenticateUserByName(CONFIG["jellyfin-username"], CONFIG["jellyfin-password"]).then((response) => {