From d469ed39690b142d1fcbb43781e01a31d01fb3a5 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Mon, 24 Oct 2022 12:47:01 -0600 Subject: [PATCH] custom log color --- bot.js | 4 ++-- src/util/log/log.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index e119d6b..8ecaf7b 100644 --- a/bot.js +++ b/bot.js @@ -7,8 +7,8 @@ log("Hello in blue", {color: 'blue'}); log('A strange warning appears!', {color: 'yellowBright', source: 'warn', sourceColor: 'yellow'}); log('Extra line spacing before', {}, false, true); log('regular line'); -client.config.logLevel = 0; log('extra line spacing after', {}, true); log('regular line'); log('both line spaces', {}, true, true); -log('regular line'); \ No newline at end of file +log('regular line'); +log('a custom fancy pink color', {color: '#ff00ff', sourceColor: '#660066'}); \ No newline at end of file diff --git a/src/util/log/log.js b/src/util/log/log.js index 5c2d8b0..dc13f7b 100644 --- a/src/util/log/log.js +++ b/src/util/log/log.js @@ -25,6 +25,6 @@ module.exports = (client) => { client.config.logLevel = getLevel(client.config.logLevel); if (client.config.logLevel < opt.level) {return;} } - console.log(`${spacer ? '\n' : ''}${chalk[opt.sourceColor](`[${opt.source.toUpperCase()}]`)}${opt.suffix}${options.nc || options.noColor ? message : chalk[opt.color](message)}${newLine ? '\n' : ''}`); + console.log(`${spacer ? '\n' : ''}${(opt.sourceColor.startsWith('#') ? chalk.hex(opt.sourceColor) : chalk[opt.sourceColor])(`[${opt.source.toUpperCase()}]`)}${opt.suffix}${options.nc || options.noColor ? message : (opt.color.startsWith('#') ? chalk.hex(opt.color) : chalk[opt.color])(message)}${newLine ? '\n' : ''}`); }; }; \ No newline at end of file