pass extra console.log args

v2
Kit Kasune 2 years ago
parent 2dadce7391
commit a5e1c4c1f9
  1. 4
      src/util/log/log.js
  2. 12
      src/util/log/types.js

@ -13,7 +13,7 @@ let defaultOptions = {
suffix: " >> " suffix: " >> "
}; };
const tlog = (client) => (message = "Test Log", options = {}, prenl = false, postnl = false) => { const tlog = (client) => (message = "Test Log", options = {}, prenl = false, postnl = false, ...multcons) => {
let opt = {}; let opt = {};
if (typeof options !== 'object') {options = {};} if (typeof options !== 'object') {options = {};}
opt.color = options.color || defaultOptions.color; opt.color = options.color || defaultOptions.color;
@ -26,7 +26,7 @@ const tlog = (client) => (message = "Test Log", options = {}, prenl = false, pos
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(`${prenl ? '\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)}${postnl ? '\n' : ''}`); console.log(`${prenl ? '\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)}${postnl ? '\n' : ''}`, ...multcons);
}; };
module.exports = (client) => { module.exports = (client) => {

@ -1,20 +1,20 @@
module.exports = (log) => { return { module.exports = (log) => { return {
error: (message, options, newLine, spacer) => log(message, { error: (message, options, prenl, postnl, ...multcons) => log(message, {
color: 'redBright', color: 'redBright',
source: 'err!', source: 'err!',
sourceColor: 'red', sourceColor: 'red',
level: 0 level: 0
}, newLine, spacer), }, prenl, postnl, ...multcons),
warn: (message, options, newLine, spacer) => log(message, { warn: (message, options, prenl, postnl, ...multcons) => log(message, {
color: 'yellowBright', color: 'yellowBright',
source: 'warn', source: 'warn',
sourceColor: 'yellow', sourceColor: 'yellow',
level: 1 level: 1
}, newLine, spacer), }, prenl, postnl, ...multcons),
success: (message, options, newLine, spacer) => log(message, { success: (message, options, prenl, postnl, ...multcons) => log(message, {
color: 'greenBright', color: 'greenBright',
source: 'proc' || options && options.source, source: 'proc' || options && options.source,
sourceColor: 'green', sourceColor: 'green',
level: options && typeof options.level !== 'undefined' ? options.level : 0 level: options && typeof options.level !== 'undefined' ? options.level : 0
}, newLine, spacer) }, prenl, postnl, ...multcons)
}}; }};
Loading…
Cancel
Save