From 501d5e3b0be37ebceda96240af1e4d8df927d68f Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 14 Aug 2024 09:23:19 +0200 Subject: improve logging on main failure (#111) * add support for indenting callstack output * Explicitly catch option-parse error and reduce log spam on bad parameters * add command line to sentry error reports * log command line at startup --- src/zenserver/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/zenserver/main.cpp') diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 023abc8a3..c27d4eb04 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -92,10 +93,9 @@ ZenEntryPoint::Run() std::string SentryDatabasePath = (m_ServerOptions.DataDir / ".sentry-native").string(); std::string SentryAttachmentPath = m_ServerOptions.AbsLogFile.string(); - Sentry.Initialize(SentryDatabasePath, SentryAttachmentPath, m_ServerOptions.SentryAllowPII); + Sentry.Initialize(SentryDatabasePath, SentryAttachmentPath, m_ServerOptions.SentryAllowPII, m_ServerOptions.CommandLine); } #endif - try { // Mutual exclusion and synchronization @@ -179,6 +179,8 @@ ZenEntryPoint::Run() InitializeServerLogging(m_ServerOptions); + ZEN_INFO("Command line: {}", m_ServerOptions.CommandLine); + #if ZEN_USE_SENTRY Sentry.LogStartupInformation(); #endif @@ -437,6 +439,12 @@ main(int argc, char* argv[]) return App.Run(); #endif } + catch (const OptionParseException& ParseEx) + { + // The parsing error already outputs all the details so no need to output the command line here + fprintf(stderr, "ERROR: %s\n", ParseEx.what()); + return 1; + } catch (const AssertException& AssertEx) { fprintf(stderr, "ERROR: Caught assert exception in main: '%s'", AssertEx.FullDescription().c_str()); -- cgit v1.2.3