diff options
| author | Dan Engelbrecht <[email protected]> | 2025-06-10 13:06:40 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2025-06-10 13:06:40 +0200 |
| commit | cadaad632b05e231dadfc977819189d9c486c74b (patch) | |
| tree | fcbfc231abfa2968b4f669a2624f647a00b2ff62 /src/zen/zen.cpp | |
| parent | add EnvironmentOptions helper (diff) | |
| download | archived-zen-cadaad632b05e231dadfc977819189d9c486c74b.tar.xz archived-zen-cadaad632b05e231dadfc977819189d9c486c74b.zip | |
add sentry configurations options for debug/environment
add env-variable parsing for sentry option
Diffstat (limited to 'src/zen/zen.cpp')
| -rw-r--r-- | src/zen/zen.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp index f0644a4f5..d19ff840e 100644 --- a/src/zen/zen.cpp +++ b/src/zen/zen.cpp @@ -37,6 +37,7 @@ #include <zencore/trace.h> #include <zencore/windows.h> #include <zenhttp/httpcommon.h> +#include <zenutil/environmentoptions.h> #include <zenutil/logging.h> #include <zenutil/zenserverprocess.h> @@ -872,18 +873,22 @@ main(int argc, char** argv) #endif // ZEN_WITH_TRACE #if ZEN_USE_SENTRY - bool NoSentry = false; - bool SentryAllowPII = false; - std::string SentryDsn; + + SentryIntegration::Config SentryConfig; + + bool NoSentry = false; + Options .add_option("sentry", "", "no-sentry", "Disable Sentry crash handler", cxxopts::value<bool>(NoSentry)->default_value("false"), ""); Options.add_option("sentry", "", "sentry-allow-personal-info", "Allow personally identifiable information in sentry crash reports", - cxxopts::value<bool>(SentryAllowPII)->default_value("false"), + cxxopts::value<bool>(SentryConfig.AllowPII)->default_value("false"), ""); - Options.add_option("sentry", "", "sentry-dsn", "Sentry DSN to send events to", cxxopts::value<std::string>(SentryDsn), ""); + Options.add_option("sentry", "", "sentry-dsn", "Sentry DSN to send events to", cxxopts::value<std::string>(SentryConfig.Dsn), ""); + Options.add_option("sentry", "", "sentry-environment", "Sentry environment", cxxopts::value<std::string>(SentryConfig.Environment), ""); + Options.add_options()("sentry-debug", "Enable debug mode for Sentry", cxxopts::value<bool>(SentryConfig.Debug)->default_value("false")); #endif Options.parse_positional({"command"}); @@ -928,6 +933,27 @@ main(int argc, char** argv) } #if ZEN_USE_SENTRY + + { + EnvironmentOptions EnvOptions; + + EnvOptions.AddOption("UE_ZEN_SENTRY_DSN"sv, SentryConfig.Dsn, "sentry-dsn"sv); + EnvOptions.AddOption("UE_ZEN_SENTRY_ALLOWPERSONALINFO"sv, SentryConfig.AllowPII, "sentry-allow-personal-info"sv); + EnvOptions.AddOption("UE_ZEN_SENTRY_ENVIRONMENT"sv, SentryConfig.Environment, "sentry-environment"sv); + + bool EnvEnableSentry = !NoSentry; + EnvOptions.AddOption("UE_ZEN_SENTRY_ENABLED"sv, EnvEnableSentry, "no-sentry"sv); + + EnvOptions.AddOption("UE_ZEN_SENTRY_DEBUG"sv, SentryConfig.Debug, "sentry-debug"sv); + + EnvOptions.Parse(ParseResult); + + if (EnvEnableSentry != !NoSentry) + { + NoSentry = !EnvEnableSentry; + } + } + SentryIntegration Sentry; if (NoSentry == false) @@ -945,7 +971,9 @@ main(int argc, char** argv) SB.Append(argv[i]); } - Sentry.Initialize(SentryDatabasePath, {}, SentryDsn, SentryAllowPII, SB.ToString()); + SentryConfig.DatabasePath = SentryDatabasePath; + + Sentry.Initialize(SentryConfig, SB.ToString()); SentryIntegration::ClearCaches(); } |