views:

63

answers:

2

Hi All, My problem is that i wish to capture the text that is displayed in the console of Xcode when an application is executed and display it in a text box in my App.

If i override NSLog i can just capture the explicit NSLog commands that are issued in the course of the program. However many statements that are just inserted by the compiler are not captured.

Is there a way to read the Xcode Console buffer while the app is running and display it in the app too ??

A: 

The Xcode Console is just a window that reads errors and such from the Console logs. Try reading from there.

Alexsander Akers
The problem still remains in this solution because although the console logs capture the NSLog statements but it doesn't log the statements printed using printf .
Rohit
A: 

What you see in the log window of Xcode is a composite of the messages that would normally go to standard out and standard error file streams and to the system log. If you want to capture those streams, you need to close them and reopen them as pipes or files.

If you do this, the documentation says that if you redirect standard error from the default, NSLog will log to that as well as the console. Thus you don't need to override it.

Redirecting standard error and standard out is a fairly common thing to do in Unix. The basic technique to redirect to a file is to close the file descriptor using close(2) and then reopen it using open(2) or pipe(2).

JeremyP