Add startup log file creation with error handling

This commit is contained in:
Jarian Cottingham 2026-02-21 16:03:47 -06:00
parent 7813490a72
commit 35f9969c80

17
main.js
View File

@ -120,13 +120,28 @@ ipcMain.handle('rename-file', async (event, { oldPath, newName }) => {
// Create log file for debugging
const fs = require('fs');
const path = require('path');
// Ensure log file exists at startup
const logFilePath = path.join(__dirname, 'app-debug.log');
try {
// Try to create or truncate the log file
fs.writeFileSync(logFilePath, `=== Application started at ${new Date().toISOString()} ===\n`);
console.log('Debug log file created successfully at:', logFilePath);
} catch (error) {
console.error('Failed to create debug log file:', error.message);
throw new Error('Cannot create debug log file - check permissions');
}
const logFilePath = __dirname + '/file-move-debug.log';
function writeLog(message) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] ${message}\n`;
try {
fs.appendFileSync(logFilePath, logEntry);
console.log(logEntry.trim());
} catch (error) {
console.error('Failed to write to log file:', error.message);
}
}
// IPC handler for moving file to folder