Skip to content

feat: implement device log capture support#60

Closed
codegen-sh[bot] wants to merge 2 commits intomainfrom
codegen-bot/implement-device-log-capture-support-a8f3d2
Closed

feat: implement device log capture support#60
codegen-sh[bot] wants to merge 2 commits intomainfrom
codegen-bot/implement-device-log-capture-support-a8f3d2

Conversation

@codegen-sh
Copy link

@codegen-sh codegen-sh bot commented Jun 8, 2025

Summary

This PR implements device log capture support for iOS devices connected via USB, addressing the feature request from issue #54.

Changes Made

New Device Log Module (src/tools/device_log.ts)

  • startDeviceLogCapture: Launches apps on iOS devices with console output capture using xcrun devicectl device process launch --console
  • stopDeviceLogCapture: Stops log capture sessions and retrieves captured logs
  • registerListDevicesTool: Lists available iOS devices with UUIDs and connection information
  • Log file management: Automatic cleanup of old log files with 3-day retention policy

Tool Registration

  • Added device log tools to IOS_DEVICE_WORKFLOW and DIAGNOSTICS tool groups
  • Registered three new tools:
    • list_devices: Lists connected iOS devices with UUIDs
    • start_device_log_cap: Starts device log capture by launching app with console output
    • stop_device_log_cap: Stops capture and returns logs

Technical Implementation

The implementation uses the xcrun devicectl device process launch --console --device UUID bundleId command that was discovered by the user in issue #54. This approach:

  • Launches the app on the device with console output capture enabled
  • Streams both stdout and stderr to log files
  • Provides session-based management similar to simulator log capture
  • Includes proper error handling and cleanup

Usage Example

// 1. List available devices
await listDevices()

// 2. Start log capture (launches app with console output)
const session = await startDeviceLogCapture({
  deviceUuid: "723AD663-26E8-5EA8-8342-77E32B826F27",
  bundleId: "com.example.myapp"
})

// 3. Interact with the app on device

// 4. Stop capture and get logs
const logs = await stopDeviceLogCapture(session.sessionId)

Resolves

Testing

  • ✅ TypeScript compilation passes
  • ✅ Build process completes successfully
  • ✅ Tool registration follows existing patterns
  • ✅ Error handling and validation implemented

💻 View my workAbout Codegen

- Add new device_log.ts module with device log capture functionality
- Implement startDeviceLogCapture using xcrun devicectl device process launch --console
- Add stopDeviceLogCapture for retrieving captured logs
- Include registerListDevicesTool for discovering connected iOS devices
- Register device log tools in IOS_DEVICE_WORKFLOW and DIAGNOSTICS groups
- Support for USB-connected iOS devices with console output capture

Resolves the feature request from issue #54 where user found working
devicectl command for capturing device logs.
@codegen-sh
Copy link
Author

codegen-sh bot commented Jun 8, 2025

I see a check failed - I'm on it! 🫡

💻 View my work

- Fixed prettier formatting issues in device_log.ts
- Applied consistent code formatting across the file
- All linting checks now pass
@codegen-sh
Copy link
Author

codegen-sh bot commented Jun 8, 2025

✅ Fixed failing CI check in this commit

The issue was prettier formatting violations in the newly added src/tools/device_log.ts file. The CI was failing on the linting step because:

  1. Inconsistent string formatting - Long template literals needed proper line breaks
  2. Inconsistent spacing - Function parameters and object properties needed consistent formatting
  3. Missing line breaks - Several long lines exceeded the prettier line length limits

Fix applied:

  • Ran npm run lint:fix to automatically resolve ESLint/Prettier formatting issues
  • Ran npm run format to ensure consistent code formatting
  • Verified all checks pass: ✅ Build ✅ Lint ✅ Format check

The device log capture functionality remains fully intact - this was purely a code formatting fix to meet the project's style guidelines.

💻 View my work • React 👍 or 👎

@cameroncooke
Copy link
Collaborator

cameroncooke commented Jun 9, 2025

Fixed in #62

Got it, the fix is in PR #62! 👍

💻 View my work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: is it possible to run on the build on hardware devices like i can do it from xcode via wifi?

1 participant