Logs

Overview

  • GPT Driver creates XCTest Attachments which can be directly viewed in XCode after a test run

  • GPT Driver also creates a Session URL which contains a log of each step executed via GPT Driver. This URL is hosted on the GPT Driver web platform.

How to retrieve the GPT Driver Session URL?

The GPTDriver session URL is made available through multiple channels:

  1. OS Logs - Structured logging with .notice level (maps to OSLogType.default)

  2. XCTest Attachments - Saved as .webloc file in test results

  3. Public Property - Accessible programmatically via driver.sessionURL

  4. Callback - onSessionCreated closure for real-time access

The session URL is automatically saved as an XCTAttachment in your test results.

Location in Test Results

The attachment is saved with:

  • Name: GPTDriver Session URL Link

  • Lifetime: .keepAlways (persists even after test completion)

  • UserInfo: Contains ["link": "<session-url>"]

  • File Format: .webloc (macOS web location file in XML format)

Extracting from .xcresult Bundle

Using Python Script

Using Swift Script

Method 2: Extract from OS Logs

The session URL is logged with .notice level using the unified logging system.

Log Format

The log entry follows this format:

Extracting from Log Files

Using log command (macOS)

Using os_log Export (CI)

If you're exporting logs in CI, you can parse them:

Method 3: Programmatic Access

Using the Public Property

Using the Callback

CI Integration Examples

GitHub Actions

Troubleshooting

Session URL Not Found

  1. Check if session was created: Ensure startSession() completed successfully

  2. Verify attachment lifetime: The attachment uses .keepAlways - check your test result bundle settings

  3. Check log level: Ensure .notice level logs are captured in your CI environment

Parsing Issues

  1. JSON format: The xcresulttool JSON output structure may vary - use recursive search

  2. Webloc format: The .webloc file is XML format - use proper XML parsing

  3. Encoding: Ensure UTF-8 encoding when reading files

Performance

  • For large test suites, extracting attachments can be slow

  • Consider using the callback method (onSessionCreated) for real-time access

  • Cache session URLs if running multiple tests

Best Practices

  1. Use the callback: Set onSessionCreated for immediate access

  2. Save to file: Write session URL to a file early in your test run

  3. Include in test reports: Attach session URL to your test reporting tool

  4. Set environment variable: Make session URL available to other CI steps

  5. Archive results: Keep .xcresult bundles for debugging

Last updated