Previously getLogDir() only checked app.isReady(), which caused development builds to write logs to the user data directory instead of the local project logs/ folder. Now uses app.isPackaged to correctly distinguish production from development environments. Also adds comprehensive logging system documentation and a debug utility for verifying Electron environment detection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
748 B
TypeScript
28 lines
748 B
TypeScript
/**
|
|
* Debug script to verify Electron environment detection
|
|
*/
|
|
import { app } from 'electron'
|
|
|
|
console.log('=== Electron Environment Debug ===\n')
|
|
|
|
console.log('1. app.isPackaged:', app.isPackaged)
|
|
console.log('2. app.getPath("userData"):', app.getPath('userData'))
|
|
console.log('3. app.getPath("logs"):', app.getPath('logs'))
|
|
console.log('4. NODE_ENV:', process.env.NODE_ENV)
|
|
console.log('5. process.cwd():', process.cwd())
|
|
console.log('6. __dirname:', __dirname)
|
|
|
|
// Predict log dir
|
|
function getLogDir(): string {
|
|
if (app && app.isReady()) {
|
|
return app.getPath('logs')
|
|
}
|
|
const devLogDir = `${process.cwd()}\\logs`
|
|
return devLogDir
|
|
}
|
|
|
|
console.log('\n7. Predicted log dir:', getLogDir())
|
|
console.log('\n=== END DEBUG ===')
|
|
|
|
app.quit()
|