With an exception in Objective-C, you receive an informative printout like the following:
-[__NSArray0 addObject:]: unrecognized selector sent to instance 0x104660
The reason is great, but often just as useful, is the first part, which tells you where the error is coming from, in this case, a non-mutable array. This got me thinking, what if NSLog displayed that too. It normally displays the time, which is nice, but most of the time it's not that useful at all, and just takes up a lot of space.
I created a Log that does just this. It outputs a message with the format "caller:message". it has two methods: ALog, which logs all the time, and DLog, which logs only on debug builds. It works exactly like NSLog, with formatting of strings. In addition, you can throw any old object in it and it will print the [object description] out.
Here is an example of usage:
If the caller is a C-function, it will have output like this, if it is from an Objective-C method the message will have the format "-[MyObject myMethod]: my message".
I'm posting the code here, and an archive is also linked at the bottom: I find that the easiest thing to do to use this, is to simply import the header file into the precompiled header for the whole project, so that I don't have to import into each file individually.
Note that my code uses DEBUG rather than NDEBUG, because by default, Xcode defines DEBUG.