iOS NSLog去掉时间戳及其他输出样式
2016-01-07 02:46
666 查看
iOS NSLog去掉时间戳及其他输出样式
1.一般项目中我的NSLog会在Prefix.pch文件添加如下代码,已保证在非调试状态下NSLog不工作
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
2.在项目中如果没做任何处理的话会输出如下信息,前面有一个时间戳
2014-11-07 08:25:40.885 zcsy[673:8937] cell的高度258.684998
我们修改下宏如下:
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s\n",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif
经过上面的修改我们可以输出 纯净的内容如下:
cell的高度258.684998
我们可以用更好的版本我推荐用这个打印我们的日志:
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif
这样我们的输出就是这样:
//它会输出文件名,和打印的具体行号
DealItemCell.m:307 cell的高度258.684998
1.一般项目中我的NSLog会在Prefix.pch文件添加如下代码,已保证在非调试状态下NSLog不工作
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
2.在项目中如果没做任何处理的话会输出如下信息,前面有一个时间戳
2014-11-07 08:25:40.885 zcsy[673:8937] cell的高度258.684998
我们修改下宏如下:
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s\n",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif
经过上面的修改我们可以输出 纯净的内容如下:
cell的高度258.684998
我们可以用更好的版本我推荐用这个打印我们的日志:
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif
这样我们的输出就是这样:
//它会输出文件名,和打印的具体行号
DealItemCell.m:307 cell的高度258.684998
相关文章推荐
- 淘宝轮播图
- CSS 样式总结
- css基础学习
- 样式的继承
- 史上最牛逼的纯CSS实现tab选项卡,闪瞎你的狗眼
- css3-选择器
- css浮动与清除浮动
- 怎么为WebStorm更换主题 修改字体样式
- CSS实现水平|垂直居中漫谈
- css011 表格和表单的格式化
- css010 css的transform transition和animation
- css008 给网页添加图片
- CSS排版
- css3-浮动制作的简单瀑布流
- css3-定位和浮动
- 如何改变Label中字符串的样式
- css properties
- web前端开发分享-css,js工具篇
- 深入理解CSS3 Animation 帧动画(step详解)
- css 实现进度条