From 8dc931eeded3eb4f84e0193d91d927386e823e04 Mon Sep 17 00:00:00 2001 From: holly Date: Fri, 3 Sep 2021 21:09:55 +0100 Subject: [PATCH] refactor consoleHelper --- consoleHelper.js | 12 ++++++------ server/util/shortUUID.js | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 server/util/shortUUID.js diff --git a/consoleHelper.js b/consoleHelper.js index 905df00..70f54fe 100644 --- a/consoleHelper.js +++ b/consoleHelper.js @@ -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())}]`); } } diff --git a/server/util/shortUUID.js b/server/util/shortUUID.js new file mode 100644 index 0000000..a863855 --- /dev/null +++ b/server/util/shortUUID.js @@ -0,0 +1,5 @@ +const uuid = require("uuid").v4; + +module.exports = function() { + return uuid().split("-").slice(0, 2).join(""); +} \ No newline at end of file