How to get rid of the date and time that appears before every NSLog statement in the console
Read these:
- https://github.com/davislg/QuietLog
- https://web.archive.org/web/20140924195139/http://cocoaheads.byu.edu/wiki/different-nslog
It's a Github project called "QuietLog", originally from our CocoaHeads site, that explains how to create a QuietLog
function that does what you're describing. It also shows how to wrap QuietLog into a macro called LocationLog so that it'll print out the file name and line number where you've got the log statement. I use it in all of my projects, and I don't lose stray "NSLog" statements anymore.
This preprocessor macro is easy to implement and you don't have to change any of your current NSLog
statements:
#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
It works completely like NSLog
without all the extra things before the message.
I original found this on another SO question, but I can't find it now.