首页 > 其他 > 详细

自定义NSLog

时间:2015-04-16 19:57:48      阅读:136      评论:0      收藏:0      [点我收藏+]

#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模式下有效。

自定义NSLog

原文:http://blog.csdn.net/workresource/article/details/45078705

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!