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: " >> "
};
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 = {};
if (typeof options !== 'object') {options = {};}
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);
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) => {

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