Commit b5af42beaab748ea6b4334df08af10dfbc0ed25d

Authored by Wiebe Cazemier
1 parent d105ac30

Add 'quiet' option to log

This mutes all INFO and NOTICE.

Also fixed the parsing of the log_subscriptions.
configfileparser.cpp
... ... @@ -96,6 +96,7 @@ ConfigFileParser::ConfigFileParser(const std::string &path) :
96 96 validKeys.insert("auth_plugin_serialize_auth_checks");
97 97 validKeys.insert("auth_plugin_timer_period");
98 98 validKeys.insert("log_file");
  99 + validKeys.insert("quiet");
99 100 validKeys.insert("allow_unsafe_clientid_chars");
100 101 validKeys.insert("allow_unsafe_username_chars");
101 102 validKeys.insert("client_initial_buffer_size");
... ... @@ -310,6 +311,12 @@ void ConfigFileParser::loadFile(bool test)
310 311 tmpSettings->logPath = value;
311 312 }
312 313  
  314 + if (key == "quiet")
  315 + {
  316 + bool tmp = stringTruthiness(value);
  317 + tmpSettings->quiet = tmp;
  318 + }
  319 +
313 320 if (key == "allow_unsafe_clientid_chars")
314 321 {
315 322 bool tmp = stringTruthiness(value);
... ...
logger.cpp
... ... @@ -157,7 +157,7 @@ void Logger::setLogPath(const std::string &path)
157 157 Logger::logPath = path;
158 158 }
159 159  
160   -void Logger::setFlags(bool logDebug, bool logSubscriptions)
  160 +void Logger::setFlags(bool logDebug, bool logSubscriptions, bool quiet)
161 161 {
162 162 if (logDebug)
163 163 curLogLevel |= LOG_DEBUG;
... ... @@ -165,9 +165,14 @@ void Logger::setFlags(bool logDebug, bool logSubscriptions)
165 165 curLogLevel &= ~LOG_DEBUG;
166 166  
167 167 if (logSubscriptions)
168   - curLogLevel |= (LOG_UNSUBSCRIBE & LOG_SUBSCRIBE);
  168 + curLogLevel |= (LOG_UNSUBSCRIBE | LOG_SUBSCRIBE);
169 169 else
170   - curLogLevel &= ~(LOG_UNSUBSCRIBE & LOG_SUBSCRIBE);
  170 + curLogLevel &= ~(LOG_UNSUBSCRIBE | LOG_SUBSCRIBE);
  171 +
  172 + if (!quiet)
  173 + curLogLevel |= (LOG_NOTICE | LOG_INFO);
  174 + else
  175 + curLogLevel &= ~(LOG_NOTICE | LOG_INFO);
171 176 }
172 177  
173 178 void Logger::quit()
... ...
logger.h
... ... @@ -75,7 +75,7 @@ public:
75 75 void noLongerLogToStd();
76 76  
77 77 void setLogPath(const std::string &path);
78   - void setFlags(bool logDebug, bool logSubscriptions);
  78 + void setFlags(bool logDebug, bool logSubscriptions, bool quiet);
79 79  
80 80 void quit();
81 81  
... ...
mainapp.cpp
... ... @@ -644,7 +644,7 @@ void MainApp::loadConfig()
644 644  
645 645 logger->setLogPath(settings->logPath);
646 646 logger->queueReOpen();
647   - logger->setFlags(settings->logDebug, settings->logSubscriptions);
  647 + logger->setFlags(settings->logDebug, settings->logSubscriptions, settings->quiet);
648 648  
649 649 setlimits();
650 650  
... ...
settings.h
... ... @@ -35,6 +35,7 @@ public:
35 35 // Actual config options with their defaults.
36 36 std::string authPluginPath;
37 37 std::string logPath;
  38 + bool quiet = false;
38 39 bool allowUnsafeClientidChars = false;
39 40 bool allowUnsafeUsernameChars = false;
40 41 bool authPluginSerializeInit = false;
... ...