Skip to content

Conversation

@loinsir
Copy link
Contributor

@loinsir loinsir commented Sep 30, 2025

Summary

Add Swift print() and debugPrint() output capture to FLEX System Log viewer. Swift print statements now appear in System Log with [SwiftPrint]
prefix alongside NSLog and os_log messages.

Changes

Core Implementation

  • FLEXSwiftPrintRedirector: New Objective-C class that redirects stdout/stderr to capture Swift print output
    • Uses NSPipe to intercept stdout/stderr file descriptors
    • Implements line buffering to handle partial pipe reads correctly
    • Callback-based architecture for direct FLEX integration without going through NSLog/os_log
    • Preserves original console output while capturing for FLEX

Integration

  • System Log view automatically enables Swift print redirection on load
  • Captured messages are directly delivered to FLEX via message handler callback
  • All Swift print output appears with [SwiftPrint] prefix for easy identification

Example App

  • Added Swift print test statements in example app timer for demonstration

Test Plan

  1. Run FLEXample app
  2. Open FLEX System Log viewer
  3. Observe Swift print statements appearing with [SwiftPrint] prefix
  4. Verify console output still works normally

@loinsir loinsir force-pushed the master branch 4 times, most recently from 901a844 to 6871cdd Compare September 30, 2025 09:32
- Implement stdout/stderr pipe redirection in Objective-C
- Capture Swift print() and debugPrint() output
- Use callback-based message handler for direct FLEX integration
- Add line buffering to handle partial pipe reads correctly
- Set message handler to receive captured Swift print output
- Enable redirection when System Log view loads
- Swift print statements now appear with [SwiftPrint] prefix
@NSExceptional NSExceptional added the AI • Caution This PR was likely created with AI and may need extra careful code review, testing, and tweaks label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI • Caution This PR was likely created with AI and may need extra careful code review, testing, and tweaks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants