标签:ios
#if DEBUG
#define NSLog(FORMAT, ...) {\
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
[dateFormatter setDateFormat:@"HH:mm:ss:SSSSSS"];\
NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
fprintf(stderr,"\ntime:%s fileName:%s line:%d function:%s content:%s\n", [str UTF8String], [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, __FUNCTION__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
}
#else
#define NSLog(FORMAT, ...) nil
#endif
note:
该自定义NSLog只在DEBUG模式下有效。
标签:ios
原文地址:http://blog.csdn.net/workresource/article/details/45078705