feat(logging-p0): add screenshot capture and browser console diagnostics for ERP errors

Enhance ERP automation error diagnostics by capturing PNG screenshots
on every error and forwarding browser console warnings/errors to the
structured logger. Includes automatic cleanup of old screenshots
aligned with the configured log retention period.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-04 14:00:48 +08:00
parent c8783a2cef
commit fce8dbc37f
8 changed files with 539 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ import DailyRotateFile from 'winston-daily-rotate-file'
import path from 'path'
import { BrowserWindow } from 'electron'
import { serializeError, sanitizeError } from './error-utils'
import { getLogDir, isProduction } from './shared'
import { getLogDir, isProduction, cleanupOldScreenshots } from './shared'
import { IPC_CHANNELS } from '../../../shared/ipc-channels'
import { getContext, run } from './request-context'
@@ -212,6 +212,9 @@ export function applyLoggingConfig(config: { level: string; appRetention: number
})
)
}
// Clean up old screenshot files beyond the retention window
cleanupOldScreenshots(config.appRetention)
}
/**