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

     

  • 相关阅读:
    代码整洁之道-格式
    代码整洁之道-函数
    redis常规命令记录
    周报2019.7.19
    docker mysql安装
    Python requirements.txt
    Javascript-关于null、undefined、空字符串的区分
    Javascript-string-Array
    取出两个二维数组中不重复的数组值方法
    让未知宽高的元素水平垂直居中
  • 原文地址:https://www.cnblogs.com/liaods/p/5169745.html
Copyright © 2011-2022 走看看