#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:%sn", [str UTF8String], [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, __FUNCTION__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
}
#else
#define NSLog(FORMAT, ...) nil
#endif
note:
該自定義NSLog只在DEBUG模式下有效。