Create custom debug log in iOS

Post date: Jul 30, 2013 10:39:50 AM

Most of time we used NSLog to debug the iOS application, which is not good practice, because it will make problem while we release the application. So we need to have custom log which is based on our compiler flag. So we can disable the log whenever we required. 

#ifdef DEBUG

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

#else

#define DLog(...)

#endif

Don't forget to add DEBUG flag in the Preprocessor Macros under Build Settings