The global object in charge of setting up and controlling crash reporting. More...
#include <CrashHandler.h>
Inherits QObject.
Public Slots | |
void | setPath (const QString &path) |
Set the directory for the crash reports. More... | |
bool | start () |
Start the crash handler. More... | |
void | startMonitor (QCoreApplication *app) |
Starts the unhandled exception monitor. More... | |
bool | isStarted () const |
Whether the crash monitor has been successfully started. More... | |
bool | isEnabled () const |
Whether the crash monitor will report crashes if they occur. More... | |
void | setEnabled (bool enabled) |
Set whether we want to submit crash reports to the report server. More... | |
void | setUrl (const QString &url) |
Set the URL where to send crash reports to. More... | |
void | setToken (const QString &token) |
Set the token for the crash reporter. More... | |
void | setAnnotation (const std::string &key, const char *value) |
Set an annotation to be added to a crash. More... | |
void | setAnnotation (const std::string &key, const QString &value) |
Set an annotation to be added to a crash. More... | |
void | setAnnotation (const std::string &key, const std::string &value) |
Set an annotation to be added to a crash. More... | |
Signals | |
void | enabledChanged (bool enabled) |
Emitted when the enabled/disabled state of the crash handler changes. More... | |
The global object in charge of setting up and controlling crash reporting.
This object initializes and talks to crash reporting backends. For those, see CrashHandlerBackend.h and the .cpp files that implement that interface.
The crash URL and token can only be passed to the underlying system on start, so things should be set up in such a way that startup is only done after those are set.
start() will be automatically called when setEnabled() is called with true. setAnnotation() can only be called after start.
To use, follow this general pattern in an application:
For an assignment client, there are two potential ways to start, through the command-line and through the settings system. Since the path, URL and token only apply on startup, the code must be written such that if command arguments are not given, setEnabled() or start() are not called until receiving the settings from the domain.
|
signal |
Emitted when the enabled/disabled state of the crash handler changes.
This can be used to store it as a setting.
enabled | Whether the crash handler is now enabled |
|
inlineslot |
Whether the crash monitor will report crashes if they occur.
This setting is independent of isCrashMonitorStarted() – crash reporting may be enabled but fail to work due to the crash reporting component being missing or failing to initialize.
|
inlineslot |
Whether the crash monitor has been successfully started.
Reasons for it failing to start include:
|
slot |
Set an annotation to be added to a crash.
Annotations add extra information, such as the application's version number, the current user, or any other information of interest.
key | Key |
value | Value |
|
slot |
Set an annotation to be added to a crash.
Annotations add extra information, such as the application's version number, the current user, or any other information of interest.
key | Key |
value | Value |
|
slot |
Set an annotation to be added to a crash.
Annotations add extra information, such as the application's version number, the current user, or any other information of interest.
key | Key |
value | Value |
|
slot |
Set whether we want to submit crash reports to the report server.
The report server is configured with CMAKE_BACKTRACE_URL. Emits crashReportingEnabledChanged signal.
enabled | Whether it's enabled. |
|
slot |
Set the directory for the crash reports.
This sets the path for writing crash reports. This should be done on application startup.
path | Directory where to store crash reports. It's allowed to set this to argv[0], if the path is a filename, then the base directory will be automatically used. |
|
slot |
Set the token for the crash reporter.
This is an identifier in the crash collection service, such as Sentry, and may contain a branch name or a version number.
If not set, a predefined token specified at compile time via CMAKE_BACKTRACE_TOKEN will be used.
token | Token |
|
slot |
Set the URL where to send crash reports to.
If not set, a predefined URL specified at compile time via CMAKE_BACKTRACE_URL will be used.
url | URL |
|
slot |
Start the crash handler.
This is called automatically if it wasn't started yet when setEnabled() is called.
path | Path where to store the crash database |
|
slot |
Starts the unhandled exception monitor.
On Windows, it's possible for the unhandled exception handler to be reset. This starts a timer to periodically set it back.
On non-Windows systems this has no effect.
app | Main application |