loggerUtility.cjs 498 B

12345678910111213141516171819
  1. // common/loggerUtility.cjs
  2. const fs = require('fs');
  3. const path = require('path');
  4. const logFilePath = path.join(__dirname, 'temporary-log.txt'); // Log file location
  5. const logData = (data) => {
  6. const timestamp = new Date().toISOString();
  7. const logEntry = `[${timestamp}] ${data}\n`;
  8. fs.appendFile(logFilePath, logEntry, (err) => {
  9. if (err) {
  10. console.error('Error writing to log file', err);
  11. }
  12. });
  13. };
  14. // Export logData using `module.exports`
  15. module.exports = { logData };