Skip to content

Log

The log module manages browser console logs and log entry events.

Methods

clear

Clear all log entries for specific contexts:

await client.log.clear(contexts=["context-id-1"])

Events

Subscribe to log.entryAdded to receive console logs in real time:

async def on_log(entry):
    print(f"[{entry.level.upper()}] {entry.text}")

client.on("log.entryAdded", on_log)
await client.session.subscribe(["log.entryAdded"])

Log entry fields

Field Type Description
level str "info", "warning", "error", "debug"
text str Log message text
timestamp int Unix timestamp (ms)
args list[RemoteValue] Structured arguments (auto-parsed)
type str Log type: "console", "javascript"
method str \| None Console method (e.g. "log", "warn", "error")
stack_trace StackTrace \| None Call stack (if available)
source ScriptSource \| None Source realm and context info

Reference

LogModule

Module for managing browser logs.

Commands
  • clear — clears the log buffer for a context
Example

await client.log.clear(context)

Source code in bidiwave/modules/log.py
class LogModule:
    """Module for managing browser logs.

    Commands:
        - clear — clears the log buffer for a context

    Example:
        await client.log.clear(context)
    """

    def __init__(self, connection: Connection) -> None:
        self._connection = connection

    async def clear(self, context: BrowsingContext | str | None = None) -> None:
        """Clears the log buffer.

        Args:
            context: BrowsingContext or context ID. None = all contexts.
        """
        params: dict[str, str] = {}
        if context is not None:
            ctx_id = context.id if hasattr(context, "id") else context
            params["context"] = ctx_id
        await self._connection.send_command(LOG_CLEAR, params)

clear async

clear(context: BrowsingContext | str | None = None) -> None

Clears the log buffer.

Parameters:

Name Type Description Default
context BrowsingContext | str | None

BrowsingContext or context ID. None = all contexts.

None
Source code in bidiwave/modules/log.py
async def clear(self, context: BrowsingContext | str | None = None) -> None:
    """Clears the log buffer.

    Args:
        context: BrowsingContext or context ID. None = all contexts.
    """
    params: dict[str, str] = {}
    if context is not None:
        ctx_id = context.id if hasattr(context, "id") else context
        params["context"] = ctx_id
    await self._connection.send_command(LOG_CLEAR, params)