Created
March 15, 2015 09:52
-
-
Save zekunyan/2f2356136b9b40348584 to your computer and use it in GitHub Desktop.
Objective-C NSLog enhance
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
#define NEED_DEBUG | |
#ifdef NEED_DEBUG | |
#define NSLog(format, ...) \ | |
do { \ | |
NSLog(@"<%@ : %d : %s>-%@", \ | |
[[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ | |
__LINE__, \ | |
__FUNCTION__, \ | |
[NSString stringWithFormat:format, ##__VA_ARGS__]); \ | |
} while(0) | |
#else | |
#define NSLog(format, ...) do{ } while(0) | |
#endif | |
#define LOG_LEVEL_DEBUG | |
#define LOG_LEVEL_INFO | |
#define LOG_LEVEL_ERROR | |
#ifdef LOG_LEVEL_DEBUG | |
#define DLog(format, ...) NSLog(@"<DEBUG>: %@", [NSString stringWithFormat:format, ##__VA_ARGS__]) | |
#else | |
#define DLog(format, ...) do{ } while(0) | |
#endif | |
#ifdef LOG_LEVEL_INFO | |
#define ILog(format, ...) NSLog(@"<Info>: %@", [NSString stringWithFormat:format, ##__VA_ARGS__]) | |
#else | |
#define ILog(format, ...) do{ } while(0) | |
#endif | |
#ifdef LOG_LEVEL_ERROR | |
#define ELog(format, ...) NSLog(@"<Error>: %@", [NSString stringWithFormat:format, ##__VA_ARGS__]) | |
#else | |
#define ELog(format, ...) do{ } while(0) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment