♻️ Refactor backend and add comments

This commit is contained in:
2022-05-19 00:22:55 +02:00
parent 73dc67e6b4
commit 9fad079102
5 changed files with 86 additions and 25 deletions

View File

@ -2,8 +2,10 @@ import fs from "fs";
export function log(type, text) {
if (!fs.existsSync("logs")) fs.mkdirSync("logs");
const logName = new Date().toISOString().split("T")[0] + ".log";
const timestamp = new Date().toISOString().replace("T", " ").split(".")[0];
const now = new Date().toISOString();
const logName = now.split("T")[0] + ".log";
const timestamp = now.replace("T", " ").split(".")[0];
const logLine = `<${timestamp}> [${type}]: ${text}`;
fs.appendFileSync("logs/" + logName, logLine + "\n");
console.log(logLine);