I am not interested in logging into frameworks or under the covers but only at my source level code upon entry and exit of each method. I would like it to provide Class Name and Method Name and log it to file or at least have it fly by on the screen.
My query is if it is possible with existing Xcode/Debugger/Instruments facilities, can I implement it in an easy way other than an NSLog statement at every method entry and exit, or is there a commercial tool that provides this capability ?
I'm talking source methods here... not execution processes or threads. Thanks.
You can enable debugging or tracing by adding a #define DEBUG or #define TRACE line to the top of your code or using the /d:DEBUG or /d:TRACE compiler switch when you compile. See the example in Listing 21.7.
Tracing helps to see the information of issues at the runtime of the application. By default Tracing is disabled. Tracing has the following important features: We can see the execution path of the page and application using the debug statement. We can access and manipulate trace messages programmatically.
Dave Dribin covers precisely this in his article Tracing Objective-C messages.
The part you are after is probably this:
If you set the
NSObjCMessageLoggingEnabled
environment variable toYES
, the Objective-C runtime will log all dispatched Objective-C messages to a file named /tmp/msgSends-<pid>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With