A better way to do NSLogging

There is much better way to do logging in your iOS apps than using NSLog directly.

The problem with that is that you have to go to every NSLog statement you have in your entire codebase whenever you want to make a change to them or want them out of your current build, etc. etc.

You would always want to remove your NSLog's before doing a release build and this could be an extremely tedious task.

Also, many people don't know that NSLog's can be very bad for performance. So whenever you would want to test whether logging is causing your performance issues and you just quickly want to remove them, you would also want a quick way to just switch logging off.

I came across this macro in a project that I was working on. It is just awesome.

#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#   define DLog(...)

Using this DLog macro your logs will automatically include the method name and the line number your logging at and this is automatically tied to your DEBUG builds. Allowing you to easily switch off all of your logs and removes them for RELEASE builds.

While doing some research, I found this macro mentioned way back when on stackoverflow so I'm guessing this where the guys working on the project got this from.