fix(logger): use app.isPackaged for log dir detection and add logging docs
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>
This commit is contained in:
27
src/main/tools/debug-env.ts
Normal file
27
src/main/tools/debug-env.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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()
|
||||
Reference in New Issue
Block a user