3 ms·
A good solution to this is to use always use a debug-mode dependent macro for logging[1]: #ifdef DEBUG #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt),__P
by danenania 14y ago
A good solution to this is to use always use a debug-mode dependent macro for logging[1]:
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt),__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
# define DLog(...)
#endif
Put that in your [Project]-Prefix.pch file to make it available globally. Aside from letting you log without fear, it gives you better performance in production, and you can get extra context for your output.
1: http://stackoverflow.com/questions/969130/how-to-print-out-the-method-name-and-line-number-and-conditionally-disable-nslog http://stackoverflow.com/questions/969130/how-to-print-out-t...