获取已发布的app错误信息:
来源:互联网 发布:如何自己查找淘宝漏洞 编辑:程序博客网 时间:2024/05/17 22:24
获取已发布的app错误信息:
第一种方法:
在uiapplication.m添加
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
NSSetUncaughtExceptionHandler(&myExceptionHandler);
}
添加以上代码
//处理异常===========
void myExceptionHandler(NSException *exception)
{
NSArray *stack = [exception callStackReturnAddresses];
NSLog(@"Stack trace: %@", stack);
NSArray *arr = [exception callStackSymbols];
NSString *reason = [exception reason];
NSString *name = [exception name];
//调用发邮件处理错误
/* NSString *urlStr = [NSString stringWithFormat:@"mailto://kfq0072@163.com?subject=bug报告&body=感谢您的配合!<br><br><br>" "错误详情:<br>%@<br>---------<br>%@<br>------<br>%@",name,reason,[arr componentsJoinedByString:@"<br>"]];
NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url]; */
//保存在txt文档中,然后在发邮件出去,文档要加密,才能添加附件成功。
NSString *txtUrl = [NSStringstringWithFormat:@"========异常崩溃报=====\nname:\n%@\nreason: \n%@\ncallStackSymbols:\n%@",name,reason,[arrcomponentsJoinedByString:@"\n"]];
NSString *path = [NSHomeDirectory()stringByAppendingPathComponent:@"Exception.txt"];
[txtUrl writeToFile:pathatomically:YESencoding:NSUTF8StringEncodingerror:nil];
NSString *urlStr = [NSStringstringWithFormat:@"mailto://kfq0072@163.com?subject=bug报告&attachment=%@&body=感谢您的配合!<br><br><br>""错误详情:<br>%@<br>---------<br>%@<br>------<br>%@",path,name,reason,[arr componentsJoinedByString:@"<br>"]];
NSURL *url = [NSURLURLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplicationsharedApplication] openURL:url];
}
第二种方法:
如果不是在模拟器上,又或者我们的设备没有连接到PC上,那么如何调试我们的程序呢?假如我们通过AdHoc发布了程序,希望随时得到测试人员的反馈,可以利用下面的方法,将标准出力(stderr)信息记录到文件中,然后通过邮件新式发给开发者。
1. 设置一个开关,用来清空日志文件内容,并切换输出位置;
1
2
3
4
5
6
7
8
- (BOOL)deleteLogFile {
[self finishLog];
BOOL success = [[NSFileManager defaultManager] removeItemAtPath:[self loggingPath] error:nil];
[self startLog];
return success;
}
当我们调用上面的deleteLogFile后,就会清空之前的日志,并设置新的输出。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- (void)finishLog {
fflush(stderr);
dup2(dup(STDERR_FILENO), STDERR_FILENO);
close(dup(STDERR_FILENO));
}
- (NSString*)loggingPath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:@"console.log"];
return logPath;
}
- (void)startLog {
freopen([[self loggingPath] cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
}
2. 当日志取得之后,可以通过下面的方式发送邮件给开发者
1
2
3
4
5
6
7
8
9
10
11
- (void)sendLogByMail {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:[NSString stringWithFormat:@"%@ - Log", [self appName]]];
NSString *message = [NSString stringWithContentsOfFile:[self loggingPath] encoding:NSUTF8StringEncoding error:nil];
[picker setMessageBody:message isHTML:NO];
[self.navigationController presentModalViewController:picker animated:YES];
[picker release];
}
- 获取已发布的app错误信息:
- android 收集已发布版本的错误信息(UncaughtExceptionHandler)
- 获取已安装APP的信息
- 获取已安装APP的apk文件
- ADB检查APP已安装列,是否已安装,获取已安装APP的版本号,
- 向appstore查询已发布的app的信息
- 段错误信息的获取
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- 向 appstore 查询已发布 APP 的信息
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- 如何向 appstore 查询已发布 APP 的信息?
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- [iOS]如何向 appstore 查询已发布 APP 的信息?
- 向 appstore 查询已发布 APP 的信息
- 如何向 appstore 查询已发布 APP 的信息?
- lalal 开学了
- [Jquery入门]----jQuery中this与$(this)的区别
- Where has the caret gone?
- mysql动态连接数据库
- 应用Excel实现大小写金额转换
- 获取已发布的app错误信息:
- Thunk技术的一些理解(一)
- 通过Z-BlogPHP程序快速在论坛里搭建一个博客页面
- ASP.NET在webconfig中配置默认启动项
- wpf笔记1
- winmm.dll API Reference for C#
- 迅通雾霾处理技术为清晰都市保驾护航
- 有return的情况下try catch finally的执行顺序
- 通过show status 来优化MySQL数据库