From b5af42beaab748ea6b4334df08af10dfbc0ed25d Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sun, 21 Nov 2021 14:16:14 +0100 Subject: [PATCH] Add 'quiet' option to log --- configfileparser.cpp | 7 +++++++ logger.cpp | 11 ++++++++--- logger.h | 2 +- mainapp.cpp | 2 +- settings.h | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/configfileparser.cpp b/configfileparser.cpp index 9211f17..168f332 100644 --- a/configfileparser.cpp +++ b/configfileparser.cpp @@ -96,6 +96,7 @@ ConfigFileParser::ConfigFileParser(const std::string &path) : validKeys.insert("auth_plugin_serialize_auth_checks"); validKeys.insert("auth_plugin_timer_period"); validKeys.insert("log_file"); + validKeys.insert("quiet"); validKeys.insert("allow_unsafe_clientid_chars"); validKeys.insert("allow_unsafe_username_chars"); validKeys.insert("client_initial_buffer_size"); @@ -310,6 +311,12 @@ void ConfigFileParser::loadFile(bool test) tmpSettings->logPath = value; } + if (key == "quiet") + { + bool tmp = stringTruthiness(value); + tmpSettings->quiet = tmp; + } + if (key == "allow_unsafe_clientid_chars") { bool tmp = stringTruthiness(value); diff --git a/logger.cpp b/logger.cpp index 2928851..871b1ad 100644 --- a/logger.cpp +++ b/logger.cpp @@ -157,7 +157,7 @@ void Logger::setLogPath(const std::string &path) Logger::logPath = path; } -void Logger::setFlags(bool logDebug, bool logSubscriptions) +void Logger::setFlags(bool logDebug, bool logSubscriptions, bool quiet) { if (logDebug) curLogLevel |= LOG_DEBUG; @@ -165,9 +165,14 @@ void Logger::setFlags(bool logDebug, bool logSubscriptions) curLogLevel &= ~LOG_DEBUG; if (logSubscriptions) - curLogLevel |= (LOG_UNSUBSCRIBE & LOG_SUBSCRIBE); + curLogLevel |= (LOG_UNSUBSCRIBE | LOG_SUBSCRIBE); else - curLogLevel &= ~(LOG_UNSUBSCRIBE & LOG_SUBSCRIBE); + curLogLevel &= ~(LOG_UNSUBSCRIBE | LOG_SUBSCRIBE); + + if (!quiet) + curLogLevel |= (LOG_NOTICE | LOG_INFO); + else + curLogLevel &= ~(LOG_NOTICE | LOG_INFO); } void Logger::quit() diff --git a/logger.h b/logger.h index 579bf28..48cbee5 100644 --- a/logger.h +++ b/logger.h @@ -75,7 +75,7 @@ public: void noLongerLogToStd(); void setLogPath(const std::string &path); - void setFlags(bool logDebug, bool logSubscriptions); + void setFlags(bool logDebug, bool logSubscriptions, bool quiet); void quit(); diff --git a/mainapp.cpp b/mainapp.cpp index 0547c32..2b5d00b 100644 --- a/mainapp.cpp +++ b/mainapp.cpp @@ -644,7 +644,7 @@ void MainApp::loadConfig() logger->setLogPath(settings->logPath); logger->queueReOpen(); - logger->setFlags(settings->logDebug, settings->logSubscriptions); + logger->setFlags(settings->logDebug, settings->logSubscriptions, settings->quiet); setlimits(); diff --git a/settings.h b/settings.h index ecc627a..06edf5f 100644 --- a/settings.h +++ b/settings.h @@ -35,6 +35,7 @@ public: // Actual config options with their defaults. std::string authPluginPath; std::string logPath; + bool quiet = false; bool allowUnsafeClientidChars = false; bool allowUnsafeUsernameChars = false; bool authPluginSerializeInit = false; -- libgit2 0.21.4