diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 4 | ||||
| -rw-r--r-- | src/lib/config.h | 10 | ||||
| -rw-r--r-- | src/lib/dcpomatic_sentry.cc | 58 | ||||
| -rw-r--r-- | src/lib/dcpomatic_sentry.h | 26 | ||||
| -rw-r--r-- | src/lib/wscript | 4 |
5 files changed, 102 insertions, 0 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 267831341..e07be6b3d 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -222,6 +222,7 @@ Config::set_defaults() _player_http_server_port = 8080; _relative_paths = false; _layout_for_short_screen = false; + _enable_crash_reporting = false; _allowed_dcp_frame_rates.clear(); _allowed_dcp_frame_rates.push_back(24); @@ -668,6 +669,7 @@ try _player_http_server_port = f.optional_number_child<int>("PlayerHTTPServerPort").get_value_or(8080); _relative_paths = f.optional_bool_child("RelativePaths").get_value_or(false); _layout_for_short_screen = f.optional_bool_child("LayoutForShortScreen").get_value_or(false); + _enable_crash_reporting = f.optional_bool_child("EnableCrashReporting").get_value_or(false); #ifdef DCPOMATIC_GROK if (auto grok = f.optional_node_child("Grok")) { @@ -1157,6 +1159,8 @@ Config::write_config() const cxml::add_text_child(root, "RelativePaths", _relative_paths ? "1" : "0"); /* [XML] LayoutForShortScreen 1 to set up DCP-o-matic as if the screen were less than 800 pixels high */ cxml::add_text_child(root, "LayoutForShortScreen", _layout_for_short_screen ? "1" : "0"); + /* [XML] EnableCrashReporting 1 to make DCP-o-matic automatically upload crash reports for analysis */ + cxml::add_text_child(root, "EnableCrashReporting", _enable_crash_reporting ? "1" : "0"); #ifdef DCPOMATIC_GROK _grok.as_xml(cxml::add_child(root, "Grok")); diff --git a/src/lib/config.h b/src/lib/config.h index 582e90cf9..afa22ab68 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -122,6 +122,7 @@ public: GROK, #endif CINEMAS_FILE, + ENABLE_CRASH_REPORTING, OTHER }; @@ -689,6 +690,10 @@ public: return _layout_for_short_screen; } + bool enable_crash_reporting() { + return _enable_crash_reporting; + } + /* SET (mostly) */ void set_master_encoding_threads(int n) { @@ -1265,6 +1270,10 @@ public: maybe_set(_layout_for_short_screen, layout); } + void set_enable_crash_reporting(bool error) { + maybe_set(_enable_crash_reporting, error, ENABLE_CRASH_REPORTING); + } + void changed(Property p = OTHER); boost::signals2::signal<void (Property)> Changed; @@ -1512,6 +1521,7 @@ private: int _player_http_server_port; bool _relative_paths; bool _layout_for_short_screen; + bool _enable_crash_reporting; #ifdef DCPOMATIC_GROK Grok _grok; diff --git a/src/lib/dcpomatic_sentry.cc b/src/lib/dcpomatic_sentry.cc new file mode 100644 index 000000000..e2f3ce9d5 --- /dev/null +++ b/src/lib/dcpomatic_sentry.cc @@ -0,0 +1,58 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "config.h" +#include "dcpomatic_sentry.h" +#include "version.h" +#include <sentry.h> +#include <fmt/format.h> + + +void +maybe_setup_sentry() +{ + if (!Config::instance()->enable_crash_reporting()) { + return; + } + + auto *options = sentry_options_new(); + sentry_options_set_dsn(options, "https://aa14795ff538105836cfc663e1079fb1@o4510456286347264.ingest.de.sentry.io/4510456326651984"); + // This is also the default-path. For further information and recommendations: + // https://docs.sentry.io/platforms/native/configuration/options/#database-path + sentry_options_set_database_path(options, State::write_path("sentry-database").string().c_str()); + sentry_options_set_release(options, fmt::format("dcpomatic@{}", dcpomatic_version).c_str()); +#ifdef DCPOMATIC_DEBUG + sentry_options_set_debug(options, 1); +#else + sentry_options_set_debug(options, 0); +#endif + sentry_init(options); + + sentry_close(); +} + + +void +closedown_sentry() +{ + sentry_close(); +} + diff --git a/src/lib/dcpomatic_sentry.h b/src/lib/dcpomatic_sentry.h new file mode 100644 index 000000000..d7c07543d --- /dev/null +++ b/src/lib/dcpomatic_sentry.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include <boost/filesystem.hpp> + + +void maybe_setup_sentry(); +void closedown_sentry(); diff --git a/src/lib/wscript b/src/lib/wscript index a6a6d96fc..2c0136ed1 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -272,6 +272,10 @@ def build(bld): if bld.env.ENABLE_GROK: obj.source += ' grok_j2k_encoder_thread.cc grok/util.cc' + + if bld.env.ENABLE_SENTRY: + obj.source += ' dcpomatic_sentry.cc' + obj.uselib += ' SENTRY' if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32: obj.uselib += ' WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE SETUPAPI OLE32 UUID' |
