mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
add logging prefix and colors
This commit is contained in:
parent
c717eb152c
commit
2e48f43b72
27
src/index.js
27
src/index.js
@ -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) => {
|
||||||
@ -26,4 +51,4 @@ try {
|
|||||||
discordClient.login(CONFIG.token);
|
discordClient.login(CONFIG.token);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user