首页 > 移动平台 > 详细

ios通过代码方式获取crash日志

时间:2016-01-29 20:54:57      阅读:145      评论:0      收藏:0      [点我收藏+]

1.新建GUncaughtExceptionHandler

+ (void)setDefaultHandler

{

    NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);

}

并实现方法

void UncaughtExceptionHandler(NSException *exception)

{

    NSArray *arr = [exception callStackSymbols];

    

    NSString*realErr1=[arr objectAtIndex:3];

    NSString *error1 = [realErr1 substringFromIndex:51];

    

    NSString * realErr2=[arr objectAtIndex:4];

    NSString *error2 = [realErr2 substringFromIndex:51];

    NSString * machineName =[Device machineName];

    NSString * error=[NSString stringWithFormat:@"%@=====>>>>>%@=====>>>>>%@--%@",machineName,error2,error1,exception.reason];

    JSONDAO*jsonDao =[[JSONDAO alloc]init];

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

    [dateFormatter setDateFormat: @"yy-MM-dd"];

    NSString*newTime=[dateFormatter stringFromDate:[YlwSingleMode GetCorrectiondate]];

    

    NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:[YlwSingleMode GetCorrectiondate]];

    NSString*oldTime=[dateFormatter stringFromDate:lastDay];

    [jsonDao updateSoftError:newTime errorlog:error todayDateString:oldTime];

}

2appdelegate调用方法

[GUncaughtExceptionHandler setDefaultHandler];

 

ios通过代码方式获取crash日志

原文:http://www.cnblogs.com/liaods/p/5169745.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!