From 0bb22090babbbc8873b4f159e9e10d3ac3571717 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sun, 10 Mar 2019 14:28:52 +0100 Subject: [PATCH] Replace easylogging parsing from string to explicit calls This makes sure that there are no typos in the string. And prevents the few bytes of string from being included in the final binary. --- src/utils/setup.h | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/utils/setup.h b/src/utils/setup.h index 1c51b45..99b518b 100644 --- a/src/utils/setup.h +++ b/src/utils/setup.h @@ -330,27 +330,32 @@ void reinstallApplicationManifest( const QString manifestPath ) void setUpLogging() { - constexpr auto logConfigDefault - = "* GLOBAL:\n" - " FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n" - " FILENAME = \"AdvancedSettings.log\"\n" - " ENABLED = true\n" - " TO_FILE = true\n" - " TO_STANDARD_OUTPUT = true\n" - " MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n" - "* TRACE:\n" - " ENABLED = false\n" - "* DEBUG:\n" - " ENABLED = false\n"; - - const int dummyArgc = 0; - const char** dummyArgv = {}; - START_EASYLOGGINGPP( dummyArgc, dummyArgv ); - el::Loggers::addFlag( el::LoggingFlag::DisableApplicationAbortOnFatalLog ); el::Configurations conf; - conf.parseFromText( logConfigDefault ); + conf.setToDefault(); + + using el::ConfigurationType; + using el::Level; + + conf.set( Level::Global, + ConfigurationType::Format, + "[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg" ); + conf.set( + Level::Global, ConfigurationType::Filename, "AdvancedSettings.log" ); + + constexpr auto confEnabled = "true"; + conf.set( Level::Global, ConfigurationType::Enabled, confEnabled ); + conf.set( Level::Global, ConfigurationType::ToFile, confEnabled ); + conf.set( Level::Global, ConfigurationType::ToStandardOutput, confEnabled ); + + constexpr auto TwoMegabytesInBytes = "2097152"; + conf.set( + Level::Global, ConfigurationType::MaxLogFileSize, TwoMegabytesInBytes ); + + constexpr auto confDisabled = "false"; + conf.set( Level::Trace, ConfigurationType::Enabled, confDisabled ); + conf.set( Level::Debug, ConfigurationType::Enabled, confDisabled ); // This places the log file in // Roaming/AppData/matzman666/OpenVRAdvancedSettings/AdvancedSettings.log.