const fs = require("node:fs");
const path = require("node:path");
const shared = require("./shared.js");
let logFile;

let dir = 'log/';

if (!fs.existsSync(dir)){
    fs.mkdirSync(dir);
}
  logFile = path.join(__dirname + '/' + dir, "NetBird-UptimeKuma.log");
console.log(`[${shared.now()}] File di log situato in ${__dirname}/${dir}NetBird-UptimeKuma.log`);
  
function writeToLog(message) {
  fs.appendFileSync(logFile, `${message}\n`);
}

function Log(message) {
  console.log(message);
  writeToLog(message);
}

module.exports = { Log };
