For an iPhone app, I need to collect debugging data into a file to be sent to an online service for analysis. This works fine by diverting the stderr
output to a file handle and sending the file when appropriate. (NSLog
output also ends up in stderr
, so this works across the board.) The same method also works fine with stdout
.
Here is how I do the saving to a file:
freopen(cStringFilePath, "a+", stderr) // or stdout
The above correctly returns a UnsafeMutablePointer<FILE>
which I keep track of in order to close the file when necessary.
However, I would need the content of both stdout
and stderr
in one file, with the correct time sequence line by line.
The reason for this is that I am trying to debug a third party framework which produces diagnostic output but writes it to stdout
rather to stderr
.
Any idea how to accomplish this?