Binato/consoleHelper.js

33 lines
987 B
JavaScript
Raw Normal View History

2020-08-27 13:09:35 +01:00
const chalk = require("chalk");
module.exports = {
printWebReq:function(s) {
2021-09-03 21:09:55 +01:00
console.log(`${this.getTime()} ${chalk.bgGreen(chalk.black(" WEBREQ "))} ${s}`);
2020-08-27 13:09:35 +01:00
},
printBancho:function(s) {
2021-09-03 21:09:55 +01:00
console.log(`${this.getTime()} ${chalk.bgMagenta(chalk.black(" BANCHO "))} ${s}`);
2020-08-27 13:09:35 +01:00
},
printChat:function(s) {
2021-09-03 21:09:55 +01:00
console.log(`${this.getTime()} ${chalk.bgCyan(chalk.black(" CHATTO "))} ${s}`);
2020-08-27 13:09:35 +01:00
},
printWarn:function(s) {
2021-09-03 21:09:55 +01:00
console.warn(`${this.getTime()} ${chalk.bgYellow(chalk.black(" WARNIN "))} ${chalk.yellow(s)}`);
2020-08-27 13:09:35 +01:00
},
printError:function(s) {
2021-09-03 21:09:55 +01:00
console.error(`${this.getTime()} ${chalk.bgRed((" ERROR! "))} ${chalk.red(s)}`);
2020-08-27 13:09:35 +01:00
},
getTime:function() {
const time = new Date();
2021-09-03 21:09:55 +01:00
return chalk.green(`[${correctValue(time.getHours())}:${correctValue(time.getMinutes())}:${correctValue(time.getSeconds())}]`);
2020-08-27 13:09:35 +01:00
}
}
function correctValue(i) {
if (i <= 9) return "0"+i;
else return i;
}