refactor consoleHelper

This commit is contained in:
Holly Stubbs 2021-09-03 21:09:55 +01:00
parent 2485638760
commit 8dc931eede
2 changed files with 11 additions and 6 deletions

View file

@ -2,28 +2,28 @@ const chalk = require("chalk");
module.exports = {
printWebReq:function(s) {
console.log(`${chalk.green("["+this.getTime()+"]")} ${chalk.bgGreen((" WEBREQ "))} ${s}`);
console.log(`${this.getTime()} ${chalk.bgGreen(chalk.black(" WEBREQ "))} ${s}`);
},
printBancho:function(s) {
console.log(`${chalk.green("["+this.getTime()+"]")} ${chalk.bgMagenta((" BANCHO "))} ${s}`);
console.log(`${this.getTime()} ${chalk.bgMagenta(chalk.black(" BANCHO "))} ${s}`);
},
printChat:function(s) {
console.log(`${chalk.green("["+this.getTime()+"]")} ${chalk.bgCyan((" CHAT "))} ${s}`);
console.log(`${this.getTime()} ${chalk.bgCyan(chalk.black(" CHATTO "))} ${s}`);
},
printWarn:function(s) {
console.warn(`${chalk.green("["+this.getTime()+"]")} ${chalk.bgYellow((" WARN "))} ${chalk.yellow(s)}`);
console.warn(`${this.getTime()} ${chalk.bgYellow(chalk.black(" WARNIN "))} ${chalk.yellow(s)}`);
},
printError:function(s) {
console.error(`${chalk.green("["+this.getTime()+"]")} ${chalk.bgRed((" ERROR "))} ${chalk.red(s)}`);
console.error(`${this.getTime()} ${chalk.bgRed((" ERROR! "))} ${chalk.red(s)}`);
},
getTime:function() {
const time = new Date();
return `${correctValue(time.getHours())}:${correctValue(time.getMinutes())}:${correctValue(time.getSeconds())}`;
return chalk.green(`[${correctValue(time.getHours())}:${correctValue(time.getMinutes())}:${correctValue(time.getSeconds())}]`);
}
}

5
server/util/shortUUID.js Normal file
View file

@ -0,0 +1,5 @@
const uuid = require("uuid").v4;
module.exports = function() {
return uuid().split("-").slice(0, 2).join("");
}