Re: Where does printf go?
Re: Where does printf go?
- Subject: Re: Where does printf go?
- From: "Glenn L. Austin" <email@hidden>
- Date: Tue, 28 Oct 2014 11:57:45 -0700
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 <email@hidden> 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 <email@hidden>:
>
>> This email sent to email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden