aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoaquim Rocha <jrocha@igalia.com>2010-11-11 12:52:30 +0100
committerHolger Schröder <holger.schroeder.ext@basyskom.de>2010-11-12 13:15:29 +0100
commitdbb0cfd20cede7c24ac7da5e7c6cc2d4532db4ac (patch)
tree4840ee15c4847d0c294f06a561aa32d7ac5d571a
parentbb87692b1b7cd02999f6e89b2651077fc04ee3db (diff)
Fixes: NB#202329 - mthemedaemon spews out lots of useless debug to syslog
RevBy: Armin Berres Details: Use a custom message handler for the mthemedaemon so it will only print messages to the stderr and make it's default output level to be critical on ARM and warning on i386.
-rw-r--r--mthemedaemon/main.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/mthemedaemon/main.cpp b/mthemedaemon/main.cpp
index afb35c92..d0499e4c 100644
--- a/mthemedaemon/main.cpp
+++ b/mthemedaemon/main.cpp
@@ -26,6 +26,11 @@
#include "keypresswaiter.h"
#endif
+namespace
+{
+ QtMsgType outputLevel = QtDebugMsg;
+}
+
static int setup_unix_signal_handlers()
{
struct sigaction sighup, sigterm, sigint;
@@ -55,6 +60,39 @@ static int setup_unix_signal_handlers()
return 0;
}
+static QtMsgType getOutputLevelFromArgs(QStringList arguments)
+{
+ QString argLevel;
+ int index = arguments.indexOf("-output-level") + 1;
+ if (index > 0 && index < arguments.length()) {
+ argLevel = arguments[index];
+ }
+
+ if (argLevel == "debug")
+ return QtDebugMsg;
+ if (argLevel == "warning")
+ return QtWarningMsg;
+ if (argLevel == "critical")
+ return QtCriticalMsg;
+
+#ifdef __arm__
+ return QtCriticalMsg;
+#else
+ return QtWarningMsg;
+#endif
+}
+
+static void mMessageHandler(QtMsgType type, const char *msg)
+{
+ if (type < outputLevel)
+ return;
+
+ fprintf(stderr, "%s\n", msg);
+
+ if (type == QtFatalMsg)
+ abort();
+}
+
int main(int argc, char **argv)
{
setup_unix_signal_handlers();
@@ -75,6 +113,9 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
+ outputLevel = getOutputLevelFromArgs(app.arguments());
+ qInstallMsgHandler(mMessageHandler);
+
// Apply custom server address, if the "-address" has been passed as argument
QString serverAddress;
int index = app.arguments().indexOf("-address");