Bugly集成

Bugly集成

Bugly是一个强大的数据统计三方集成框架、它可以集成在你的app程序中,帮助你捕获crash日志,集成十分容易,而且功能强大。

注册登录

Bugly是腾讯发布的一个三方,打开Bugly官网登录进入

2000C879-E273-4268-8B73-FC0E50A11502

点击新建产品,填写信息,完成后打开产品【设置】,记录App ID

1AB1D4A0-2808-439E-9DB5-967E4C34E5D2

6AD63046-A20D-479C-9139-6F6FFB9EE3F1

打开BuglySDK下载
下载iOSSDK,里面有个Demo,可以查看官方文档,参考Demo集成

下面是我的集成方法:

在AppDelegate.m的didFinishLaunchingWithOptions方法中,

1
[self openBuglySDK];

在AppDelegate.m添加下面方法,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//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";
}

这样就集成完了,简单吧。

-------------本文结束感谢您的阅读-------------