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
25
src/index.js
25
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) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user