logs · device_logs
This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET
Read a log: the current WebView's console, or the device's own log (logcat on Android, the unified log on an iOS simulator, and on a real iPhone what the session has captured since it started — a phone keeps no history). These call app_logs.
logs
def logs(level: str | None=None) -> list[dict]
Console output from the current WebView since the last call.
Includes uncaught errors and unhandled promise rejections. Each read drains what it returns, so it reports what happened since the last call — which is what makes "nothing was logged during this step" assertable. Capture starts when the context is entered, so a page's initial load is already over by then.
device_logs
def device_logs(app: str | None=None, level: str | None=None, lines: int | None=None) -> dict
The device's own log since the last read: logcat on Android, the unified log on an iOS simulator, what a real iPhone's session has captured.
Returns a dict with entries (each has time, level, tag, pid and
message) and skipped — lines newer than the last read that the
limit dropped, which will not come back. The first read returns the
most recent lines. A read narrowed by app or level leaves the rest
unread.
Examples
Read one app's errors from the device log
logs = device.device_logs(app="com.example.shop", level="error")
for entry in logs["entries"]:
print(entry["time"], entry["tag"], entry["message"])