feat: add share logs support#58
Conversation
Co-authored-by: Christian Theilemann <geekflyer@users.noreply.github.com>
| do { | ||
| try process.run() | ||
| process.waitUntilExit() | ||
| } catch { | ||
| return "Unable to capture unified logs: \(error.localizedDescription)" | ||
| } | ||
|
|
||
| let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? | ||
| .trimmingCharacters(in: .whitespacesAndNewlines) ?? "" | ||
| let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? | ||
| .trimmingCharacters(in: .whitespacesAndNewlines) ?? "" |
There was a problem hiding this comment.
Bug: Classic pipe deadlock — waitUntilExit() is called before reading from the pipes. If log show --last 24h produces more output than the pipe buffer (~64KB on macOS), the subprocess blocks trying to write, waitUntilExit() blocks waiting for the subprocess, and neither ever completes.
The Android side gets this right (readText() before waitFor()). The fix here is to read the pipe data before waiting:
| do { | |
| try process.run() | |
| process.waitUntilExit() | |
| } catch { | |
| return "Unable to capture unified logs: \(error.localizedDescription)" | |
| } | |
| let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? | |
| .trimmingCharacters(in: .whitespacesAndNewlines) ?? "" | |
| let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? | |
| .trimmingCharacters(in: .whitespacesAndNewlines) ?? "" | |
| do { | |
| try process.run() | |
| } catch { | |
| return "Unable to capture unified logs: \(error.localizedDescription)" | |
| } | |
| let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? | |
| .trimmingCharacters(in: .whitespacesAndNewlines) ?? "" | |
| let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? | |
| .trimmingCharacters(in: .whitespacesAndNewlines) ?? "" | |
| process.waitUntilExit() |
Review: Share Logs featureNice, clean feature addition across both platforms. The code is well-structured — good use of One bug to fix: macOS Everything else looks good — the Android |
Co-authored-by: Christian Theilemann <geekflyer@users.noreply.github.com>
Summary
logcatsnapshot with app/device diagnostics into the system share sheetorg.cliprelayunified logs plus device context via the native sharing picker