zoukankan      html  css  js  c++  java
  • ios通过代码方式获取crash日志

    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];

     

  • 相关阅读:
    面试题总结(vue面试题)
    面试题总结(css面试题)
    设置div居中显示
    关于js中iframe 中 location.href的用法
    js判断是否在iframe中
    npm git 常用命令行 记录
    mongDB数据库 小白学习
    EJS 入门学习
    bower 基础认识
    gulp 粗粗学习 记录下
  • 原文地址:https://www.cnblogs.com/liaods/p/5169745.html
Copyright © 2011-2022 走看看