From 1dadc3f88804cac0154dab7d49c694ca7b14a854 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Mon, 24 Oct 2022 03:29:05 -0600 Subject: [PATCH] loggiiggigngngngngn --- bot.js | 11 ++++++++++- src/util/log/log.js | 20 ++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index 46ad075..f8231ac 100644 --- a/bot.js +++ b/bot.js @@ -1,4 +1,13 @@ const logger = require('./src/util/log/log'); const client = {test: 'e', config: {logLevel: 1}}; const log = logger(client); -log(); \ No newline at end of file +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'); diff --git a/src/util/log/log.js b/src/util/log/log.js index 3d2ca31..cb917b4 100644 --- a/src/util/log/log.js +++ b/src/util/log/log.js @@ -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' : ''}`); }; \ No newline at end of file