Be VERY careful about redirecting stdout or stderr, do it VERY early before you 
initialize anything else.

The reason I say this: over time we've incorporated some SDKs into our apps, 
and those SDKs aren't always clean about properly logging (e.g. they get a file 
handle for stdout or stderr and continue to use it even after the file handle 
has been invalidated).  The really bad part about that behavior?  If that file 
handle gets re-used for your document -- well, your document has just gotten 
corrupted!

Moral of the story: If you're going to log output, don't assume that stdout or 
stderr never changes...

-- 
Glenn L. Austin, Computer Wizard and Race Car Driver         <><
<http://www.austinsoft.com>

> On Oct 28, 2014, at 5:52 AM, Alexander von Below <be...@mac.com> wrote:
> 
> Hello,
> 
> I have not tried it out in code, but generally, printf goes to "standard out" 
> STDOUT_FILENO (whereas NSLog goes to STDERR_FILENO)
> 
> You can redirect all of your output into a file, for example:
> 
> - (void) redirectSTDOUT {
>    NSError *error;
>    self.fileHandle = [NSFileHandle fileHandleForWritingToURL:self.tmpFileURL 
> error:&error];
>    self.fileDescriptor = [self.fileHandle fileDescriptor];
> 
>    dup2(self.fileDescriptor, STDOUT_FILENO);
> }
> 
> Now, all of your stdout code will go to into a file.
> 
> While this does not exactly answer your question, maybe it helps
> 
> Alex
> 
> Am 28.10.2014 um 11:13 schrieb Jonathan Taylor 
> <jonathan.tay...@glasgow.ac.uk>:
> 
>> This email sent to be...@mac.com
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (Xcode-users@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/xcode-users/glenn%40austinsoft.com
> 
> This email sent to gl...@austinsoft.com


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (Xcode-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to