Add startup log file creation with error handling
This commit is contained in:
parent
ad6c9b0d8d
commit
7717315c84
17
main.js
17
main.js
@ -120,13 +120,28 @@ ipcMain.handle('rename-file', async (event, { oldPath, newName }) => {
|
|||||||
|
|
||||||
// Create log file for debugging
|
// Create log file for debugging
|
||||||
const fs = require('fs');
|
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) {
|
function writeLog(message) {
|
||||||
const timestamp = new Date().toISOString();
|
const timestamp = new Date().toISOString();
|
||||||
const logEntry = `[${timestamp}] ${message}\n`;
|
const logEntry = `[${timestamp}] ${message}\n`;
|
||||||
|
try {
|
||||||
fs.appendFileSync(logFilePath, logEntry);
|
fs.appendFileSync(logFilePath, logEntry);
|
||||||
console.log(logEntry.trim());
|
console.log(logEntry.trim());
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to write to log file:', error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPC handler for moving file to folder
|
// IPC handler for moving file to folder
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user