2024-12-08 20:00:26 +05:00
|
|
|
import chalk from "chalk";
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
function format(tDate) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return new Intl.DateTimeFormat("ru-RU", {
|
|
|
|
year: "numeric",
|
|
|
|
month: "2-digit",
|
|
|
|
day: "2-digit",
|
|
|
|
hour: "2-digit",
|
|
|
|
minute: "2-digit",
|
|
|
|
second: "2-digit",
|
|
|
|
}).format(tDate);
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2024-12-08 20:00:26 +05:00
|
|
|
const logLevels = {
|
|
|
|
LOG: chalk.bgBlue("LOG"),
|
|
|
|
WARN: chalk.black.bgYellow("WARN"),
|
|
|
|
ERROR: chalk.black.bgRed("ERROR"),
|
|
|
|
DEBUG: chalk.green("DEBUG"),
|
|
|
|
CMD: chalk.black.bgWhite("CMD"),
|
|
|
|
READY: chalk.black.bgGreen("READY"),
|
|
|
|
};
|
|
|
|
|
2024-12-05 20:15:07 +05:00
|
|
|
export default {
|
|
|
|
log(content) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return console.log(`[${format(Date.now())}]: ${logLevels.LOG} ${content}`);
|
2024-12-05 20:15:07 +05:00
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2024-12-05 20:15:07 +05:00
|
|
|
warn(content) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return console.log(`[${format(Date.now())}]: ${logLevels.WARN} ${content}`);
|
2024-12-05 20:15:07 +05:00
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2024-12-05 20:15:07 +05:00
|
|
|
error(content) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return console.log(`[${format(Date.now())}]: ${logLevels.ERROR} ${content}`);
|
2024-12-05 20:15:07 +05:00
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2024-12-05 20:15:07 +05:00
|
|
|
debug(content) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return console.log(`[${format(Date.now())}]: ${logLevels.DEBUG} ${content}`);
|
2024-12-05 20:15:07 +05:00
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2024-12-05 20:15:07 +05:00
|
|
|
cmd(content) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return console.log(`[${format(Date.now())}]: ${logLevels.CMD} ${content}`);
|
2024-12-05 20:15:07 +05:00
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2024-12-05 20:15:07 +05:00
|
|
|
ready(content) {
|
2024-12-08 20:00:26 +05:00
|
|
|
return console.log(`[${format(Date.now())}]: ${logLevels.READY} ${content}`);
|
2024-12-05 20:15:07 +05:00
|
|
|
},
|
2023-07-05 00:58:06 +05:00
|
|
|
};
|