工作备忘-设置Log日志打印开关
2015-11-18 09:57
525 查看
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> 在制作SDK时,经常要打印日志调试,但是发布时又不想要打印日志(十分消耗性能),并且将制作好得SDK交给他人使用时,为了给予他人良好的用户体验,设置打印Log日志开关就十分有必要了。</span>
接着,
static BOOL HJ_isEnableInterfaceDebug = NO;
@implementation HJLogSwitch
+ (void)enableInterfaceDebug:(BOOL)isDebug {
HJ_isEnableInterfaceDebug = isDebug;
}
+ (BOOL)isDebug {
return HJ_isEnableInterfaceDebug;
}
+ (void)show{
if ([self isDebug]) {
DebugLog(@"日志处理");
}
}
@end
最后,调用:
[HJLogSwitch enableInterfaceDebug:YES];
[HJLogSwitch show];
哦了,搞定。
思路很简单,就是一装B利器。
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">首先:</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"></span><pre name="code" class="objc">// 项目打包发布上线不会打印日志,可放心。 #ifdef DEBUG #define DebugLog(s, ... ) NSLog( @"[%@:in line: %d]-->[message: %@]", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] ) #else #define DebugLog(s, ... ) #endif
接着,
static BOOL HJ_isEnableInterfaceDebug = NO;
@implementation HJLogSwitch
+ (void)enableInterfaceDebug:(BOOL)isDebug {
HJ_isEnableInterfaceDebug = isDebug;
}
+ (BOOL)isDebug {
return HJ_isEnableInterfaceDebug;
}
+ (void)show{
if ([self isDebug]) {
DebugLog(@"日志处理");
}
}
@end
最后,调用:
[HJLogSwitch enableInterfaceDebug:YES];
[HJLogSwitch show];
哦了,搞定。
思路很简单,就是一装B利器。
相关文章推荐
- LeetCode Move Zeroes
- git 恢复文件修改
- SharePoint自动化系列——Add/Remove “Hold” from items
- Spring data jpa实现CRUD的三种方式
- Mushroom User's Manual
- merge into 当using后的select结果为空时,不能执行update和insert
- 学习博客
- iOS之 动态热修补技术JSPatch
- Arduino系列教程之 – PWM的秘密
- Spring IoC
- 通过ZBOSS实现2530/2531 uart/usb wireshark 抓RF包(sniffer)
- navigationbar背景图 设置左右按钮
- 堆栈溢出问题(无限循环导致)
- matlab:clear,close,clc
- iOS 求两经纬度中心点,并返回缩放级别,可以参考
- Android中ImageView的图片宽度设置
- 对象排序
- 编译单个Java文件引入jar包
- IOS开发核心语言0bjective C
- 黑马程序员——OC基础04—block、protocol