feat: add console output file option for debugging and monitoring

Add comprehensive console logging to file functionality:
- CLI option --console-output-file to specify output file path
- Environment variable PLAYWRIGHT_MCP_CONSOLE_OUTPUT_FILE support
- Session configuration via browser_configure_snapshots tool
- Real-time structured logging with timestamp, session ID, and URL
- Automatic directory creation and graceful error handling
- Captures all console message types (log, error, warn, page errors)

Useful for debugging browser interactions and monitoring console activity
during automated sessions.
This commit is contained in:
Ryan Malloy 2025-08-24 14:12:00 -06:00
parent ec8b0c24b5
commit 7de63b5bab
6 changed files with 64 additions and 2 deletions

View file

@ -641,6 +641,7 @@ export class Context {
includeSnapshots?: boolean;
maxSnapshotTokens?: number;
differentialSnapshots?: boolean;
consoleOutputFile?: string;
}): void {
// Update configuration at runtime
if (updates.includeSnapshots !== undefined)
@ -659,5 +660,9 @@ export class Context {
this.resetDifferentialSnapshot();
}
if (updates.consoleOutputFile !== undefined)
(this.config as any).consoleOutputFile = updates.consoleOutputFile === '' ? undefined : updates.consoleOutputFile;
}
}