Created
December 29, 2012 03:16
-
-
Save dedmons/4404328 to your computer and use it in GitHub Desktop.
Improved Logging macros for Objective-C Development.
These are modified versions of the solutions here:
http://stackoverflow.com/questions/969130/how-to-print-out-the-method-name-and-line-number-and-conditionally-disable-nslog To disable DLog and ULog just a property or method to a class named dontLog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
# define DLog(fmt, ...) if(![self respondsToSelector:@selector(dontLog)]) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
# define DLog(...) | |
#endif | |
#ifdef DEBUG | |
# define ULog(fmt, ...) if(![self respondsToSelector:@selector(dontLog)]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; } | |
#else | |
# define ULog(...) | |
#endif | |
// ALog always displays output regardless of the DEBUG setting | |
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment