| 150 | |
| 151 | // Create backend log file |
| 152 | function createBackendLogFile() { |
| 153 | const debugLogDir = path.join(app.getPath('userData'), 'debug') |
| 154 | if (!fs.existsSync(debugLogDir)) { |
| 155 | fs.mkdirSync(debugLogDir, { recursive: true }) |
| 156 | } |
| 157 | |
| 158 | const timestamp = new Date().toISOString().replace(/[:.]/g, '-') |
| 159 | const logFileName = `backend-${timestamp}.log` |
| 160 | const logFilePath = path.join(debugLogDir, logFileName) |
| 161 | |
| 162 | // Create the log file with initial headers |
| 163 | const initialLog = `=== VIKINGDB Backend Debug Log === |
| 164 | Started: ${new Date().toISOString()} |
| 165 | Platform: ${process.platform} |
| 166 | Architecture: ${process.arch} |
| 167 | Node version: ${process.version} |
| 168 | Electron version: ${process.versions.electron} |
| 169 | Process execPath: ${process.execPath} |
| 170 | Process cwd: ${process.cwd()} |
| 171 | __dirname: ${__dirname} |
| 172 | Resources path: ${process.resourcesPath} |
| 173 | Is packaged: ${isPackaged} |
| 174 | Actually dev: ${actuallyDev} |
| 175 | ======================================== |
| 176 | |
| 177 | ` |
| 178 | |
| 179 | fs.writeFileSync(logFilePath, initialLog) |
| 180 | safeLog.log(`Created backend log file: ${logFilePath}`) |
| 181 | |
| 182 | return logFilePath |
| 183 | } |
| 184 | |
| 185 | // Helper function to log to backend log file |
| 186 | export function logToBackendFile(message) { |