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,6 +96,7 @@ ConfigFileParser::ConfigFileParser(const std::string &path) :
96 validKeys.insert("auth_plugin_serialize_auth_checks"); 96 validKeys.insert("auth_plugin_serialize_auth_checks");
97 validKeys.insert("auth_plugin_timer_period"); 97 validKeys.insert("auth_plugin_timer_period");
98 validKeys.insert("log_file"); 98 validKeys.insert("log_file");
  99 + validKeys.insert("quiet");
99 validKeys.insert("allow_unsafe_clientid_chars"); 100 validKeys.insert("allow_unsafe_clientid_chars");
100 validKeys.insert("allow_unsafe_username_chars"); 101 validKeys.insert("allow_unsafe_username_chars");
101 validKeys.insert("client_initial_buffer_size"); 102 validKeys.insert("client_initial_buffer_size");
@@ -310,6 +311,12 @@ void ConfigFileParser::loadFile(bool test) @@ -310,6 +311,12 @@ void ConfigFileParser::loadFile(bool test)
310 tmpSettings->logPath = value; 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 if (key == "allow_unsafe_clientid_chars") 320 if (key == "allow_unsafe_clientid_chars")
314 { 321 {
315 bool tmp = stringTruthiness(value); 322 bool tmp = stringTruthiness(value);
logger.cpp
@@ -157,7 +157,7 @@ void Logger::setLogPath(const std::string &path) @@ -157,7 +157,7 @@ void Logger::setLogPath(const std::string &path)
157 Logger::logPath = path; 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 if (logDebug) 162 if (logDebug)
163 curLogLevel |= LOG_DEBUG; 163 curLogLevel |= LOG_DEBUG;
@@ -165,9 +165,14 @@ void Logger::setFlags(bool logDebug, bool logSubscriptions) @@ -165,9 +165,14 @@ void Logger::setFlags(bool logDebug, bool logSubscriptions)
165 curLogLevel &= ~LOG_DEBUG; 165 curLogLevel &= ~LOG_DEBUG;
166 166
167 if (logSubscriptions) 167 if (logSubscriptions)
168 - curLogLevel |= (LOG_UNSUBSCRIBE & LOG_SUBSCRIBE); 168 + curLogLevel |= (LOG_UNSUBSCRIBE | LOG_SUBSCRIBE);
169 else 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 void Logger::quit() 178 void Logger::quit()
logger.h
@@ -75,7 +75,7 @@ public: @@ -75,7 +75,7 @@ public:
75 void noLongerLogToStd(); 75 void noLongerLogToStd();
76 76
77 void setLogPath(const std::string &path); 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 void quit(); 80 void quit();
81 81
mainapp.cpp
@@ -644,7 +644,7 @@ void MainApp::loadConfig() @@ -644,7 +644,7 @@ void MainApp::loadConfig()
644 644
645 logger->setLogPath(settings->logPath); 645 logger->setLogPath(settings->logPath);
646 logger->queueReOpen(); 646 logger->queueReOpen();
647 - logger->setFlags(settings->logDebug, settings->logSubscriptions); 647 + logger->setFlags(settings->logDebug, settings->logSubscriptions, settings->quiet);
648 648
649 setlimits(); 649 setlimits();
650 650
settings.h
@@ -35,6 +35,7 @@ public: @@ -35,6 +35,7 @@ public:
35 // Actual config options with their defaults. 35 // Actual config options with their defaults.
36 std::string authPluginPath; 36 std::string authPluginPath;
37 std::string logPath; 37 std::string logPath;
  38 + bool quiet = false;
38 bool allowUnsafeClientidChars = false; 39 bool allowUnsafeClientidChars = false;
39 bool allowUnsafeUsernameChars = false; 40 bool allowUnsafeUsernameChars = false;
40 bool authPluginSerializeInit = false; 41 bool authPluginSerializeInit = false;