Created
November 12, 2012 03:20
-
-
Save DanBrooker/4057310 to your computer and use it in GitHub Desktop.
NSLogger Macros
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 DWarn(...) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"Warning",1,__VA_ARGS__) | |
#define DErr(...) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"Error",0,__VA_ARGS__) | |
#ifdef DEBUG | |
#define NSLog(...) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"NSLog",4,__VA_ARGS__) | |
#define DLog(...) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"General",2,__VA_ARGS__) | |
#define DLogC(tag,...) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@#tag,3,__VA_ARGS__) | |
#define DData(nsdata) LogDataF(__FILE__,__LINE__,__FUNCTION__,@"NSData",2, nsdata) | |
#if TARGET_OS_IPHONE | |
#define DImage(nsimage) LogImageDataF(__FILE__,__LINE__,__FUNCTION__,@"NSImage",2, nsimage.size.width, nsimage.size.height, [[[NSBitmapImageRep alloc] initWithData:[nsimage TIFFRepresentation]] representationUsingType:NSPNGFileType properties:nil]); | |
#else | |
#define DImage(uiimage) LogImageDataF(__FILE__,__LINE__,__FUNCTION__,@"UIImage",2, uiimage.size.width, uiimage.size.height, UIImagePNGRepresentation(uiimage)); | |
#endif | |
#else | |
#define NSLog(...) (void)0; | |
#define DLog(...) (void)0; | |
#define DLogC(tag,...) (void)0; | |
#define DData(nsdata) (void)0; | |
#define DImage(uiimage) (void)0; | |
#endif | |
#undef assert | |
#if defined(DEBUG) && !defined(NDEBUG) | |
#if __DARWIN_UNIX03 | |
#define assert(e) \ | |
(__builtin_expect(!(e), 0) ? (CFShow(CFSTR("assert going to fail, connect NSLogger NOW\n")), LoggerFlush(NULL,YES), __assert_rtn(__func__, __FILE__, __LINE__, #e)) : (void)0) | |
#else | |
#define assert(e) \ | |
(__builtin_expect(!(e), 0) ? (CFShow(CFSTR("assert going to fail, connect NSLogger NOW\n")), LoggerFlush(NULL,YES), __assert(#e, __FILE__, __LINE__)) : (void)0) | |
#endif | |
#else | |
#define assert(e) (void)0 | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment