From 016e5ebc4a8b4e377434fadc0d9f4956f63e129c Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 8 Jan 2020 23:01:54 +0100 Subject: [PATCH] Add switch for enabling debug symbols and logs Enabling the switch on release builds will optimize the binaries as normal, but will still include debug symbols. This is advantageous for bugs that do not show up in debug builds without optimizations. --- advancedSettings.pro | 5 +++++ docs/building_for_linux.md | 1 + src/utils/setup.cpp | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index 46d5cee..8298880 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -118,3 +118,8 @@ unix { INSTALLS += application } +debugSymbolsAndLogs { + message(Debug symbols and logging enabled.) + CONFIG += force_debug_info + DEFINES += ENABLE_DEBUG_LOGGING +} diff --git a/docs/building_for_linux.md b/docs/building_for_linux.md index 8260af5..8a4d138 100644 --- a/docs/building_for_linux.md +++ b/docs/building_for_linux.md @@ -334,6 +334,7 @@ The following values can be appended to the `CONFIG` internal variable in order | ----- | ------- | | `noX11` | Disables X11 specific features (VR to keyboard input). | | `noDBUS` | Disables DBUS specific features (control media players). | +| `debugSymbolsAndLogs` | Enables debug symbols and debug logging calls (while still having release optimizations). | The values are case sensitive. diff --git a/src/utils/setup.cpp b/src/utils/setup.cpp index 995c592..ba5942b 100644 --- a/src/utils/setup.cpp +++ b/src/utils/setup.cpp @@ -1,4 +1,9 @@ #include "setup.h" +#ifdef ENABLE_DEBUG_LOGGING +constexpr auto debugLoggingEnabled = true; +#else +constexpr auto debugLoggingEnabled = false; +#endif // The default Qt message handler prints to stdout on X11 and to the debugger on // Windows. That is borderline useless for us, therefore we create our own @@ -317,7 +322,15 @@ void setUpLogging() constexpr auto confDisabled = "false"; conf.set( Level::Trace, ConfigurationType::Enabled, confDisabled ); - conf.set( Level::Debug, ConfigurationType::Enabled, confDisabled ); + + if constexpr ( debugLoggingEnabled ) + { + conf.set( Level::Debug, ConfigurationType::Enabled, confEnabled ); + } + else + { + conf.set( Level::Debug, ConfigurationType::Enabled, confDisabled ); + } const auto appDataLocation = std::string( "/" ) + application_strings::applicationOrganizationName