// logService.js const fs = require('fs'); const util = require('util'); // Convert fs.writeFile to a promise-based function const writeFile = util.promisify(fs.writeFile); // Ensure the log file exists and is accessible const logFilePath = 'showy.log'; fs.open(logFilePath, 'a', (err, fd) => { if (err) { console.error("Failed to open log file:", err); } else { fs.close(fd, (err) => { if (err) console.error("Failed to close log file:", err); }); } }); // Asynchronous function to append a message to the log file async function logToFile(message) { try { await writeFile(logFilePath, `${message}\n`, { flag: 'a' }); } catch (err) { console.error("Failed to write to log file:", err); } } module.exports = { logToFile, };