const fs = require("fs"); const file = fs.createWriteStream("server.log", { flags: "a" }); const label = (color, str) => `\x1b[${color}m[${str}]\x1b[0m` const log = (color, label) => (text) => { const time = new Date().toLocaleString(); file.write(`[${time}] [${label}] ${text}\n`); console.log(`\x1b[90m[${time}] \x1b[${color}m[${label}]\x1b[0m ${text}`); } module.exports = { info: log("34", "I"), warn: log("33", "W"), error: log("31", "E"), debug: log("35", "D"), };