custom log color

v2
Kit Kasune 2 years ago
parent a74538f085
commit d469ed3969
  1. 2
      bot.js
  2. 2
      src/util/log/log.js

@ -7,8 +7,8 @@ log("Hello in blue", {color: 'blue'});
log('A strange warning appears!', {color: 'yellowBright', source: 'warn', sourceColor: 'yellow'}); log('A strange warning appears!', {color: 'yellowBright', source: 'warn', sourceColor: 'yellow'});
log('Extra line spacing before', {}, false, true); log('Extra line spacing before', {}, false, true);
log('regular line'); log('regular line');
client.config.logLevel = 0;
log('extra line spacing after', {}, true); log('extra line spacing after', {}, true);
log('regular line'); log('regular line');
log('both line spaces', {}, true, true); log('both line spaces', {}, true, true);
log('regular line'); log('regular line');
log('a custom fancy pink color', {color: '#ff00ff', sourceColor: '#660066'});

@ -25,6 +25,6 @@ module.exports = (client) => {
client.config.logLevel = getLevel(client.config.logLevel); client.config.logLevel = getLevel(client.config.logLevel);
if (client.config.logLevel < opt.level) {return;} 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' : ''}`);
}; };
}; };
Loading…
Cancel
Save