loggiiggigngngngngn

v2
Kit Kasune 2 years ago
parent 0859e78ebd
commit 1dadc3f888
  1. 9
      bot.js
  2. 18
      src/util/log/log.js

@ -2,3 +2,12 @@ const logger = require('./src/util/log/log');
const client = {test: 'e', config: {logLevel: 1}}; const client = {test: 'e', config: {logLevel: 1}};
const log = logger(client); const log = logger(client);
log(); log();
log("Hello World!")
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');
log('extra line spacing after', {}, true);
log('regular line');
log('both line spaces', {}, true, true);
log('regular line');

@ -1,3 +1,19 @@
export const log = (client) => (log = "Test Log", options = {}) => { const chalk = require('chalk');
let defaultOptions = {
color: "white",
source: "USER",
sourceColor: "gray",
level: 1,
suffix: " >> "
};
module.exports = (client) => (message = "Test Log", options = {}, newLine = false, spacer = false) => {
let opt = {};
opt.color = options.color || defaultOptions.color;
opt.level = ['string', 'number'].includes(typeof options.level) ? options.level : defaultOptions.level;
opt.suffix = typeof options.suffix === 'string' ? options.suffix : defaultOptions.suffix;
opt.source = options.source || defaultOptions.source;
opt.sourceColor = options.sourceColor || defaultOptions.sourceColor;
console.log(`${spacer ? '\n' : ''}${chalk[opt.sourceColor](`[${opt.source.toUpperCase()}]`)}${opt.suffix}${options.nc || options.noColor ? message : chalk[opt.color](message)}${newLine ? '\n' : ''}`);
}; };
Loading…
Cancel
Save