Get previous launch crash logs on iPhone

I am trying to write a crash report function that, when you launch the application after a crash, will offer to send a crash report to the server. I can not find how to get the crash log in the application. I saw that there is a framework that does this ( PLCrashReporter ), however this structure is large, and I do not need most of its functions.

Does anyone know how easy it is to access the magazine?

Thanks Guy.

+4
source share
4 answers

I had a similar problem and PLCrashReported seemed too complicated for what I wanted to do. Please note that you cannot access the crash report generated by Apple, PLCrashReport generates its own reports and saves them in the user folder.

In the end, I used the following example: http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html

it is very simple and easy to use, just register exceptions and signal handlers using:

NSSetUncaughtExceptionHandler(&HandleException); signal(SIGABRT, SignalHandler); signal(SIGILL, SignalHandler); signal(SIGSEGV, SignalHandler); signal(SIGFPE, SignalHandler); signal(SIGBUS, SignalHandler); signal(SIGPIPE, SignalHandler); 

and get the stack trace using the backtrace method in the UncaughtExceptionHandler class.

+5
source

I think I do not have karma to add a comment to Nimrod Ghat, so I must provide my observation here. I will try to make it worthy of a separate answer.

It is very, very difficult to write a reliable, correct and reliable fault reporter, especially one that works directly in the process. The code mentioned in Nimrod Ghat's answer is incorrect and honest that the blog post should be canceled. Signal handlers should only run asynchronous code, and this code is not safe for asynchronous use:

http://www.cocoadev.com/index.pl?SignalSafety

Error handling is even more complicated than normal signal processing because you cannot expect the process to continue to run successfully after your signal handler returns.

It's tempting to think that you can just hack a simpler solution and it will work for a while, but there is a good reason why people like Google engineers have thousands of LoCs designed to reliably report crashes:

http://code.google.com/p/google-breakpad/

On iOS, you should just use PLCrashReporter. On other platforms (e.g. Mac OS X) you should use the Google Breakpad. It makes no sense to reinvent this wheel if you do not only do it right, but better than what already exists.

+14
source

Maybe the best solution would be to use a fully specialized 2-end solution / service? For example http://apphance.com . It is currently in a closed beta phase, but you can ask for participation and we will get back to you pretty quickly. The only thing you need to do is register the API key and insert a small frame library into your application (or .jar file in android). Then you have remote access not only to crashlogs, but also to the debug logs generated by the application, which makes it much more useful. At the moment, it is intended for testing during testing, but soon there will be a version with a light version that you can embed in an application released in applications.

Inside the framework, we are doing our best to connect to the Apple infrastructure and get information about the crash log, decode stack stacks, and even process cases from memory. All comments from @nupark are very true: we spent countless hours making it work without interruptions - thread safety, making sure that we can cope with the task of saving only the time required by the Apple framework before your application finally getting the stack trace from memory without memory (it was really complicated). The same for android - we did some clever tricks to make sure that it really works fine.

Disclaimer: I am the CTO of Polidea, the company behind the poster and co-author of the solution.

+4
source

There are many (SAAS) E2E solutions that you might be very happy to know.

Very easy to integrate into your application

Enjoy...

These days you can use the built-in crash reports (iOS and Android)

0
source

Source: https://habr.com/ru/post/1336168/


All Articles