• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem getting notifications from standard error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem getting notifications from standard error


  • Subject: Re: Problem getting notifications from standard error
  • From: Rick Hoge <email@hidden>
  • Date: Wed, 15 Feb 2006 09:33:07 -0500


Thanks -


I'd expect the getData: method to be called whenever stderr gets written to, but it never seems to be invoked.


stderr is write-only, so you'll never get something read from it. Redirection of stderr can be done in your parent process, only. Redirecting stderr to stdin isn't difficult, then.



Makes sense - I was just trying to start from an approach I'd seen in a couple of other (partial) examples. It had occurred to me that it would make more sense to use NSFileHandleDataAvailableNotification and waitForDataInBackgroundAndNotify instead. However as you point out, stderr is write-only... still at least one of the examples hinted that someone got this kind of approach (catching NSFileHandle notifications on writes to stderr) to work. See the last post in http://forums.macnn.com/showthread.php?p=2513840 - "Brass" seems to imply that he was able to direct logging activity to an NSTextView using NSFileHandle. Does not say what he did though and it's an old thread.


I also considered using freopen, but this is more suitable if you want to send the logging output to a file.


If anyone has an idea of what the problem or solution is, I'd be very grateful.


Usual solution is to replace NSLog() and implement some MyLog(). To catch system written NSLog()'s, something more sophisticated is needed, like poseAsClass(NSException) or some linking hackery to override the original NSLog().



I was thinking of this - however we have a large app that supports 3d party plugins and I was trying for a solution that would work even if people used NSLog().



P.S.: Please don't tell me you want this because you're too lazy to implement something around -[NSString stringWithFormat:].


I'm not sure what you mean, so hopefully this is not what I'm trying to do :)


What I'm really trying to achieve is something like the behavior of Apple's Disk Utility, where you can click the "Log" item on the menu bar and a window opens with an NSTextView that shows all the logging output from the appliction. Since Disk Utility is probably a wrapper for a bunch of command-line tools that are launched with NSTask, the inner workings are probably a bit different.

Thanks for the reply,

Rick


- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Problem getting notifications from standard error (From: Rick Hoge <email@hidden>)
 >Re: Problem getting notifications from standard error (From: Markus Hitter <email@hidden>)

  • Prev by Date: Re: Problem getting notifications from standard error
  • Next by Date: Re: CoreImage: Newbie can't find memory leak [SOLVED
  • Previous by thread: Re: Problem getting notifications from standard error
  • Next by thread: deleted class files from a xcdatamodel file
  • Index(es):
    • Date
    • Thread