introduce headless param

This commit is contained in:
Cynthia Long
2026-03-17 14:18:09 +00:00
parent fc7a269f0a
commit abb4583554
3 changed files with 9 additions and 5 deletions
+6 -5
View File
@@ -13,6 +13,7 @@ interface ConsolePatcherParams {
onNewMessage?: (message: Omit<ConsoleMessageItem, 'id'>) => void;
debugMode: boolean;
stderr?: boolean;
headlessMode?: boolean;
}
export class ConsolePatcher {
@@ -49,15 +50,15 @@ export class ConsolePatcher {
private patchConsoleMethod =
(type: 'log' | 'warn' | 'error' | 'debug' | 'info') =>
(...args: unknown[]) => {
if (this.params.stderr) {
if (this.params.headlessMode) {
if ((type === 'info' || type === 'log') && !this.params.debugMode) {
return;
}
if (type !== 'debug' || this.params.debugMode) {
}
if (type !== 'debug' || this.params.debugMode) {
if (this.params.stderr) {
this.originalConsoleError(this.formatArgs(args));
}
} else {
if (type !== 'debug' || this.params.debugMode) {
} else {
this.params.onNewMessage?.({
type,
content: this.formatArgs(args),