How to receive crash / freeze reports of applications, daemons and OSX programmatically?

I know that there is a way to get crashes and freezes for all applications. These files are placed in "/ Users / user / Library / Logs / DiagnosticReports". So I could get the version, time and name of the application.

But how to get the daemon / process crashes and freezes? I need to know exactly which demon was broken / hanged, and the time when this happened.

Is there also a way to get a single system (OSX) crash with the same information?

It would also be great to get some resource crashes / warnings: from memory or from disk space.

I need to do this programmatically.

On Windows, we can do this using the NotifyChangeEventLog () API. We can collect all this data using this method. He also notifies if something has happened.

+4
source share
2 answers

For a report of crashes and crashes of the daemon, see the directory "/ Library / Logs / DiagnosticReports". According to this document , you can also find kernel panic reports there (for example, system crashes).
I do not know about the NotifyChangeEventLog-like API, but in situations like "from memory" there will be an exception, so you just need to catch it. See the Error Programming Guide for more information. Also see Exception Programming Topics

Edit : For information on Crash Reporter, see Chapter 5 of Levin’s book "Mac OS X and iOS Internals: Apple Core"

+2
source

In 10.9, the activity monitor offers you two tools if you have a hang, but no crashes, so there is no crash report:

spindump - a memory dump, such as crash report and sys digs, that creates a set of files

+1
source

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