是否遇到过在 Xcode 未运行,直接在真机上调试但此时出现 bug,想看到日志输出却无法看到时的尴尬呢...
现在有了这个工具 WPLogOutputer
,这些烦恼都没有了,快来试试吧
使用简单,只需一两步就拥有,快来试试吧
WPLogOutputer
文件夹拖入项目中】PrefixHeader.pch
中导入主头文件:#import "WPLogOutputer.h"
NSLog
,以便打印出我们想要的日志格式,方便找出日志打印所在的代码行//#ifndef kAppStore
#define NSLog(FORMAT, ...) {NSString *log = [NSString stringWithFormat:FORMAT, ##__VA_ARGS__];fprintf(stderr,"\n%s %d -> %s\n", __FUNCTION__, __LINE__, [log UTF8String]);[WPLogOutputer printLog:[NSString stringWithFormat:@"%s<Line:%d>:%@", __FUNCTION__, __LINE__,[NSString stringWithFormat:@"%@",log]]];}
#else
#define NSLog(FORMAT, ...) nil
#endif
3.在适当时候将日志打印工具显示出来,如在AppDelegate中开启日志打印控件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 开启打印
[WPLogOutputer showLogOutputer];
return YES;
}
// 推荐做法
{
// 放在项目中的BaseViewController中
UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerIncident:)];
singleFingerOne.numberOfTouchesRequired = 3;// 手指数
singleFingerOne.numberOfTapsRequired = 5;// 点击次数
[self.view addGestureRecognizer:singleFingerOne];
}
- (void)fingerIncident:(UITapGestureRecognizer *)ges {
[WPLogOutputer showLogOutputer];
}
WPLog(FORMAT, ...)
来直接将想要打印的内容输出到离线日志打印神器上使用就是这样轻松!