diff --git a/src/index.js b/src/index.js index ac1576a..93c95b1 100644 --- a/src/index.js +++ b/src/index.js @@ -10,9 +10,34 @@ try { handleChannelMessage } = require("./messagehandler"); 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"]); + + 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(); // TODO Error Checking as the apiclients is inefficent jellyfinClientManager.getJellyfinClient().authenticateUserByName(CONFIG["jellyfin-username"], CONFIG["jellyfin-password"]).then((response) => { @@ -26,4 +51,4 @@ try { discordClient.login(CONFIG.token); } catch (error) { console.error(error); -} +} \ No newline at end of file