Bugly集成
Bugly是一个强大的数据统计三方集成框架、它可以集成在你的app程序中,帮助你捕获crash日志,集成十分容易,而且功能强大。
注册登录
Bugly是腾讯发布的一个三方,打开Bugly官网登录进入
点击新建产品,填写信息,完成后打开产品【设置】,记录App ID
打开BuglySDK下载
下载iOSSDK,里面有个Demo,可以查看官方文档,参考Demo集成
下面是我的集成方法:
在AppDelegate.m的didFinishLaunchingWithOptions方法中,
[self openBuglySDK];
在AppDelegate.m添加下面方法,
//BuglySDK
- (void)openBuglySDK{
BuglyConfig *config = [[BuglyConfig alloc] init];
config.reportLogLevel = BuglyLogLevelWarn;
config.blockMonitorEnable = YES;
config.blockMonitorTimeout = 2;
config.consolelogEnable = YES;
config.channel = @"Bugly";
config.delegate = self;
config.reportLogLevel = BuglyLogLevelWarn;
[Bugly startWithAppId:BuglySDK_appID //AppID
#if DEBUG
developmentDevice:YES
#endif
config:config];
[Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];
[Bugly setUserValue:[NSProcessInfo processInfo].processName forKey:@"Process"];
[self performSelectorInBackground:@selector(testLogOnBackground) withObject:nil];
}
- (void)testLogOnBackground {
int cnt = 0;
while (1) {
cnt++;
switch (cnt % 5) {
case 0:
BLYLogError(@"Test Log Print %d", cnt);
break;
case 4:
BLYLogWarn(@"Test Log Print %d", cnt);
break;
case 3:
BLYLogInfo(@"Test Log Print %d", cnt);
BLYLogv(BuglyLogLevelWarn, @"BLLogv: Test", NULL);
break;
case 2:
BLYLogDebug(@"Test Log Print %d", cnt);
BLYLog(BuglyLogLevelError, @"BLLog : %@", @"Test BLLog");
break;
case 1:
default:
BLYLogVerbose(@"Test Log Print %d", cnt);
break;
}
// print log interval 1 sec.
sleep(1);
}
}
#pragma mark -BuglyDelegate
- (NSString *)attachmentForException:(NSException *)exception {
NSLog(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);
return @"This is an attachment";
}
这样就集成完了,简单吧。