Problem redirecting NSLog() output to stderr
Problem redirecting NSLog() output to stderr
- Subject: Problem redirecting NSLog() output to stderr
- From: "email@hidden" <email@hidden>
- Date: Sun, 17 Aug 2008 22:10:18 +0100
Hello List
My app consists of a GUI process, a daemon and a number of worker
processes.
Each of these processes has their stderr redirected via freopen() to
the same log file.
For the purposes of simple logging this arrangement works acceptably.
There is a thread on why this should be: http://www.cocoabuilder.com/archive/message/cocoa/2003/6/16/3689
The user may however delete the shared log from the GUI.
After this the daemon and worker process log output is lost.
In those cases can I detect that the stderr stream is no longer valid?
I have tried fcntl(), fileno(), fstat(), ftell() and feof() without
success.
My actual call to NSLog() is wrapped in a generic logging class.
My only solution so far is to issue freopen(logfile, "a", stderr)
prior to each and every call to NSLog().
But this seems brutal.
Jonathan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden