diff options
| author | Dan Engelbrecht <[email protected]> | 2025-05-06 16:50:57 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-05-06 16:50:57 +0200 |
| commit | 6d9ff7e404a22ed1cc7e529cfa77ef7d593d9547 (patch) | |
| tree | 5cfea359c44b02fe72ab5b166e9b03900444fcba /src/zen/zen.cpp | |
| parent | cleanup changelog (diff) | |
| download | archived-zen-6d9ff7e404a22ed1cc7e529cfa77ef7d593d9547.tar.xz archived-zen-6d9ff7e404a22ed1cc7e529cfa77ef7d593d9547.zip | |
add sentry for zen command (#373)
* refactor sentry integration and add to zen command line tool
* move add_ldflags("-framework Security")
Diffstat (limited to 'src/zen/zen.cpp')
| -rw-r--r-- | src/zen/zen.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp index 399c43990..7c21035c0 100644 --- a/src/zen/zen.cpp +++ b/src/zen/zen.cpp @@ -32,6 +32,7 @@ #include <zencore/logging.h> #include <zencore/process.h> #include <zencore/scopeguard.h> +#include <zencore/sentryintegration.h> #include <zencore/string.h> #include <zencore/trace.h> #include <zencore/windows.h> @@ -581,6 +582,8 @@ ProgressBar::HasActiveTask() const int main(int argc, char** argv) { + zen::SetCurrentThreadName("main"); + std::vector<std::string> Args; #if ZEN_PLATFORM_WINDOWS LPWSTR RawCommandLine = GetCommandLine(); @@ -838,6 +841,38 @@ main(int argc, char** argv) #endif // ZEN_WITH_TRACE Options.parse_positional({"command"}); +#if ZEN_USE_SENTRY + bool NoSentry = false; + bool SentryAllowPII = false; + Options.add_options()("no-sentry", "Disable Sentry crash handler", cxxopts::value<bool>(NoSentry)->default_value("false")); + Options.add_options()("sentry-allow-personal-info", + "Allow personally identifiable information in sentry crash reports", + cxxopts::value<bool>(SentryAllowPII)->default_value("false")); +#endif + +#if ZEN_USE_SENTRY + SentryIntegration Sentry; + + if (NoSentry == false) + { + std::string SentryDatabasePath = (GetRunningExecutablePath().parent_path() / ".sentry-native").string(); + + ExtendableStringBuilder<512> SB; + for (int i = 0; i < argc; ++i) + { + if (i) + { + SB.Append(' '); + } + + SB.Append(argv[i]); + } + + Sentry.Initialize(SentryDatabasePath, {}, SentryAllowPII, SB.ToString()); + + SentryIntegration::ClearCaches(); + } +#endif const bool IsNullInvoke = (argc == 1); // If no arguments are passed we want to print usage information |