UNPKG

xc-mcp

Version:

MCP server that wraps Xcode command-line tools for iOS/macOS development workflows

19 lines 5.8 kB
/** * Stream Console Logs from Simulator * * Real-time log streaming with filtering and capture * * Full documentation: See src/tools/simctl/stream-logs.md * * @param args Tool arguments * @returns Log streaming result */ export declare function streamLogsTool(args: any): Promise<{ content: { type: "text"; text: string; }[]; isError: boolean; }>; export declare const SIMCTL_STREAM_LOGS_DOCS = "\n# simctl-stream-logs\n\nStream real-time console logs from iOS simulator with filtering and capture.\n\n## What it does\n\nStreams console logs from a simulator in real-time, with support for filtering by process\nor custom predicates. Captures logs for a specified duration and returns structured log\nentries with timestamps and process information.\n\n## Parameters\n\n- **udid** (string, required): Simulator UDID (from simctl-list)\n- **bundleId** (string, optional): Filter logs to specific app bundle ID\n- **predicate** (string, optional): Custom NSPredicate for log filtering\n- **duration** (number, optional): Capture duration in seconds (default: 10)\n- **capture** (boolean, optional): Whether to capture logs (default: true)\n\n## Returns\n\nJSON response with:\n- Captured log entries with timestamps and process names\n- Log count and duration\n- Filter information (predicate, bundleId)\n- Guidance for log analysis\n\n## Examples\n\n### Stream all logs for 10 seconds\n```typescript\nawait streamLogsTool({\n udid: 'device-123'\n})\n```\n\n### Stream logs for specific app\n```typescript\nawait streamLogsTool({\n udid: 'device-123',\n bundleId: 'com.example.MyApp',\n duration: 30\n})\n```\n\n### Stream with custom predicate\n```typescript\nawait streamLogsTool({\n udid: 'device-123',\n predicate: 'eventMessage CONTAINS \"Error\" OR eventMessage CONTAINS \"Warning\"',\n duration: 20\n})\n```\n\n## Predicate Syntax\n\nSupports NSPredicate syntax for filtering:\n- **Process filtering**: `process == \"MyApp\"`\n- **Content filtering**: `eventMessage CONTAINS \"keyword\"`\n- **Severity filtering**: `messageType == \"Error\"`\n- **Combined filters**: `process == \"MyApp\" AND eventMessage CONTAINS \"network\"`\n\nCommon predicates:\n- `process == \"com.example.MyApp\"` - Filter by bundle ID\n- `eventMessage CONTAINS \"Error\"` - Show only errors\n- `subsystem == \"com.example.networking\"` - Filter by subsystem\n- `messageType IN {\"Error\", \"Fault\"}` - Show errors and faults\n\n## Common Use Cases\n\n1. **App debugging**: Stream logs for specific app during testing\n2. **Error monitoring**: Filter for errors and warnings\n3. **Network debugging**: Monitor network-related log messages\n4. **Performance tracking**: Capture logs during performance tests\n5. **Integration testing**: Verify expected log output during test runs\n\n## Log Entry Structure\n\nEach log entry includes:\n```typescript\n{\n timestamp: \"2025-01-23 14:30:45.123\", // Extracted timestamp\n process: \"MyApp\", // Process name\n message: \"Full log line text\" // Complete log message\n}\n```\n\n## Important Notes\n\n- **Timeout buffer**: Command timeout is duration + 5 seconds for safety\n- **Buffer size**: 10MB buffer for log capture to prevent overflow\n- **First 100 logs**: Returns first 100 log entries to avoid token overflow\n- **Real-time capture**: Logs are captured as they occur during duration\n- **Simulator must be running**: Logs can only be streamed from booted simulators\n\n## Error Handling\n\n- **Missing udid**: Error if udid is not provided\n- **Simulator not found**: Validates simulator exists\n- **Command timeout**: Times out if duration exceeds limit\n- **Buffer overflow**: May lose logs if output exceeds 10MB buffer\n\n## Performance Considerations\n\n- **Duration**: Longer durations capture more logs but take more time\n- **Filtering**: Specific predicates reduce log volume and improve performance\n- **Token usage**: First 100 logs returned to keep response size manageable\n- **Buffer limit**: 10MB buffer prevents memory issues with verbose logging\n\n## Testing Workflow\n\n1. **Launch app**: `simctl-launch <udid> <bundleId>`\n2. **Start log streaming**: `simctl-stream-logs <udid> <bundleId> duration:30`\n3. **Perform actions**: Use app features that generate logs\n4. **Review logs**: Check captured logs for expected output\n5. **Debug issues**: Use log messages to identify problems\n\n## Log Analysis Tips\n\n- **Search for errors**: Look for \"Error\", \"Fault\", \"Warning\" in messages\n- **Track flow**: Follow log sequences to understand execution flow\n- **Performance metrics**: Look for timing and performance-related logs\n- **Network activity**: Monitor network requests and responses\n- **Crash detection**: Look for crash logs or assertion failures\n\n## Duration Guidelines\n\n- **Quick check**: 5-10 seconds for basic log verification\n- **Feature testing**: 15-30 seconds for testing specific features\n- **Integration tests**: 30-60 seconds for full test scenarios\n- **Debug sessions**: 60+ seconds for deep debugging sessions\n\n## Predicate Examples\n\n### Filter by app\n```\nprocess == \"com.example.MyApp\"\n```\n\n### Show only errors and warnings\n```\nmessageType == \"Error\" OR messageType == \"Warning\"\n```\n\n### Network-related logs\n```\nsubsystem == \"com.apple.network\" OR eventMessage CONTAINS \"network\"\n```\n\n### Exclude system processes\n```\nprocess BEGINSWITH \"com.example.\"\n```\n\n## Limitations\n\n- **Output truncation**: Only first 100 logs returned in response\n- **No log persistence**: Logs are not saved to disk\n- **Single capture**: Each call captures logs for one duration only\n- **No streaming to response**: Logs captured in batch after duration completes\n"; //# sourceMappingURL=stream-logs.d.ts.map