simulator.log_stream.start
Begin streaming iOS Simulator system logs to monitor application behavior and debug React Native/Expo development in real-time.
Instructions
Start streaming simulator system logs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/simulator/logs.ts:19-76 (handler)Core implementation of startLogStream(): starts a log streaming process using 'xcrun simctl spawn booted log stream', handles output via logger, manages process stateexport async function startLogStream(): Promise<LogStreamInfo> { logger.info("simulator", "Starting simulator log stream"); if (logStreamProcess) { throw createError("SIMCTL_FAILED", "Log stream is already running"); } // Check if simulator is booted if (!stateManager.isSimulatorReady()) { const bootedDevice = await getBootedDevice(); if (!bootedDevice) { throw createError("SIM_NOT_BOOTED", "No simulator is currently booted", { details: "Boot a simulator first using simulator.boot", }); } stateManager.updateSimulator({ state: "booted", udid: bootedDevice.udid, deviceName: bootedDevice.name, }); } // Start log stream logStreamProcess = execa("xcrun", ["simctl", "spawn", "booted", "log", "stream", "--style", "compact"], { reject: false, }); isStreaming = true; const startedAt = new Date().toISOString(); // Process stdout line by line logStreamProcess.stdout?.on("data", (chunk: Buffer) => { const lines = chunk.toString().split("\n").filter(Boolean); for (const line of lines) { logger.debug("simulator", line); } }); logStreamProcess.stderr?.on("data", (chunk: Buffer) => { const lines = chunk.toString().split("\n").filter(Boolean); for (const line of lines) { logger.warn("simulator", `[stderr] ${line}`); } }); logStreamProcess.on("exit", (code: number | null) => { logger.info("simulator", `Log stream ended with code ${code}`); isStreaming = false; logStreamProcess = null; }); logger.info("simulator", "Simulator log stream started"); return { isStreaming: true, startedAt, }; }
- src/mcp/server.ts:230-249 (registration)MCP server.tool registration for 'simulator.log_stream.start', which invokes startLogStream() and formats the MCP responseserver.tool( "simulator.log_stream.start", "Start streaming simulator system logs", {}, async () => { try { const result = await startLogStream(); return { content: [ { type: "text", text: JSON.stringify({ success: true, ...result }, null, 2), }, ], }; } catch (error) { return handleToolError(error); } } );