2022-01-04 02:18:28 +05:00
|
|
|
const { bgBlue, black, green } = require("chalk");
|
|
|
|
|
|
|
|
function dateTimePad(value, digits) {
|
|
|
|
let number = value;
|
|
|
|
while (number.toString().length < digits) number = "0" + number;
|
|
|
|
|
|
|
|
return number;
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
function format(tDate) {
|
2023-07-05 00:58:06 +05:00
|
|
|
return (
|
|
|
|
dateTimePad(tDate.getDate(), 2) +
|
|
|
|
"-" +
|
|
|
|
dateTimePad(tDate.getMonth() + 1, 2) +
|
|
|
|
"-" +
|
|
|
|
dateTimePad(tDate.getFullYear(), 2) +
|
|
|
|
" " +
|
|
|
|
dateTimePad(tDate.getHours(), 2) +
|
|
|
|
":" +
|
|
|
|
dateTimePad(tDate.getMinutes(), 2) +
|
|
|
|
":" +
|
|
|
|
dateTimePad(tDate.getSeconds(), 2) +
|
|
|
|
"." +
|
|
|
|
dateTimePad(tDate.getMilliseconds(), 3)
|
|
|
|
);
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
module.exports = class Logger {
|
2024-02-06 21:45:53 +05:00
|
|
|
static log(content) {
|
2022-01-04 02:18:28 +05:00
|
|
|
const date = `[${format(new Date(Date.now()))}]:`;
|
2024-02-06 21:45:53 +05:00
|
|
|
|
|
|
|
return console.log(`${date} ${bgBlue("LOG")} ${content}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
static warn(content) {
|
|
|
|
const date = `[${format(new Date(Date.now()))}]:`;
|
|
|
|
|
|
|
|
return console.log(`${date} ${black.bgYellow("WARN")} ${content}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
static error(content) {
|
|
|
|
const date = `[${format(new Date(Date.now()))}]:`;
|
|
|
|
|
|
|
|
return console.log(`${date} ${black.bgRed("ERROR")} ${content}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
static debug(content) {
|
|
|
|
const date = `[${format(new Date(Date.now()))}]:`;
|
|
|
|
|
|
|
|
return console.log(`${date} ${green("DEBUG")} ${content}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
static cmd(content) {
|
|
|
|
const date = `[${format(new Date(Date.now()))}]:`;
|
|
|
|
|
|
|
|
return console.log(`${date} ${black.bgWhite("CMD")} ${content}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ready(content) {
|
|
|
|
const date = `[${format(new Date(Date.now()))}]:`;
|
|
|
|
|
|
|
|
return console.log(`${date} ${black.bgGreen("READY")} ${content}`);
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
2023-07-05 00:58:06 +05:00
|
|
|
};
|