fix(logger): use will-quit instead of before-quit and remove redundant console.error
Move logger close from before-quit to will-quit to keep the logger available for uncaughtException handlers that may fire during shutdown. Remove 4 redundant console.error calls that duplicate Winston logger output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,6 @@ export function setupProcessGuards(): void {
|
||||
status: 'failure',
|
||||
metadata: { error: err.message, stack: err.stack }
|
||||
})
|
||||
console.error('Uncaught exception:', err)
|
||||
setTimeout(() => process.exit(1), 1000)
|
||||
})
|
||||
|
||||
@@ -25,21 +24,21 @@ export function setupProcessGuards(): void {
|
||||
status: 'failure',
|
||||
metadata: { reason: String(reason) }
|
||||
})
|
||||
console.error('Unhandled Rejection:', reason)
|
||||
})
|
||||
|
||||
app.on('render-process-gone', (_, webContents, details) => {
|
||||
logger.error('Render process gone', { details, webContentsId: webContents.id })
|
||||
console.error('Render process gone:', details)
|
||||
})
|
||||
|
||||
app.on('child-process-gone', (_, details) => {
|
||||
logger.error('Child process gone', { details })
|
||||
console.error('Child process gone:', details)
|
||||
})
|
||||
|
||||
// Flush and close loggers before quit to prevent log loss
|
||||
app.on('before-quit', () => {
|
||||
// Flush and close loggers on will-quit (fires after all windows are closed,
|
||||
// but before the event loop stops). Using will-quit instead of before-quit
|
||||
// ensures the logger remains available for uncaughtException handlers that
|
||||
// may fire between before-quit and actual process exit.
|
||||
app.on('will-quit', () => {
|
||||
logger.close()
|
||||
closeAuditLogger()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user