1
2
3
| @import AppCenter;
@import AppCenterAnalytics;
@import AppCenterCrashes;
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| #if DEBUG
[MSAppCenter start:@"cd7b7975-741c-4b4d-b595-5670035db133" withServices:@[
[MSAnalytics class],
[MSCrashes class]
]];
#else
[MSAppCenter start:@"f942ab9b-96b2-405a-a27a-d9b4ce7048b1" withServices:@[
[MSAnalytics class],
[MSCrashes class],
]];
#endif
[MSCrashes setEnabled:YES];
[MSCrashes setDelegate:self];
[MSAppCenter setLogLevel:MSLogLevelVerbose];
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| - (NSArray<MSErrorAttachmentLog *> *)attachmentsWithCrashes:(MSCrashes *)crashes
forErrorReport:(MSErrorReport *)errorReport {
MSErrorAttachmentLog *attachment1 = [MSErrorAttachmentLog attachmentWithText:errorReport.yy_modelToJSONString filename:@"crash.txt"];
NSString *logPath = [[LKLFilePathManager docPath] stringByAppendingString:@"/log"];
NSLog(@"logPath: %@", logPath);
NSString *currentTime = [LKLTimeFormat date:[LKLTimeFormat getTimeStamp] format:LKLTimeFormatSimpleYMD];
NSString *fileName = [NSString stringWithFormat:@"LKLEdu_%@", currentTime];
NSData *crashData = [LKLFilePathManager readFileData:[NSString stringWithFormat:@"%@/%@.xlog", logPath, fileName]];
if (crashData) {
MSErrorAttachmentLog *attachment2 = [MSErrorAttachmentLog attachmentWithBinary:crashData filename:fileName contentType:@"xlog"];
return @[ attachment1, attachment2 ];
}
return @[ attachment1 ];
}
|