feat(logging-p0): replace console.* with logger and add error logging before ERP throws

Eliminate console.* remnants in bootstrap, session-manager, migrations, and app entry
so startup and login failures are captured in log files. Add log.error before all 14
throw sites in ERP services (auth, extractor, cleaner, browser manager) to ensure
critical automation failures are traceable. Introduce capturePageContext utility for
defensive Playwright page state capture during error logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-04 12:12:41 +08:00
parent 018d524fe8
commit 12a17eccb7
10 changed files with 128 additions and 24 deletions

View File

@@ -6,6 +6,10 @@ import type {
ExtractorCoreResult,
ExtractionProgress
} from '../../types/extractor.types'
import { createLogger } from '../logger'
import { capturePageContext } from './erp-error-context'
const log = createLogger('ExtractorCore')
/**
* ExtractorCore - Handles all web page operations for data extraction
@@ -97,6 +101,9 @@ export class ExtractorCore {
const fFrame = await forwardFrameLocator.contentFrame()
if (!fFrame) {
log.error('Failed to access popup forward frame', {
...(await capturePageContext(popupPage))
})
throw new Error('Failed to access popup forward frame')
}
@@ -105,6 +112,7 @@ export class ExtractorCore {
const workFrame = await innerFrameLocator.contentFrame()
if (!workFrame) {
log.error('Failed to access inner work frame')
throw new Error('Failed to access inner work frame')
}