Rohit
Rohit

Reputation: 13

Capture text in Xcode's console window

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 ??

Upvotes: 1

Views: 718

Answers (2)

JeremyP
JeremyP

Reputation: 86651

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).

Upvotes: 1

Alexsander Akers
Alexsander Akers

Reputation: 16024

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

Upvotes: 0

Related Questions