From 7a5e24216d9ab827890ca0c0ddb045ad61c328b3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 23 Jan 2017 16:59:14 +0100 Subject: Feed qt debug messages into the same stream as the rest. --- synchronizer/main.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'synchronizer') diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index b228248..ff97e6a 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp @@ -134,6 +134,33 @@ void terminateHandler() std::abort(); } +/* + * We capture all qt debug messages in the same process and feed it into the sink debug system. + * This way we get e.g. kimap debug messages as well together with the rest. + */ +void qtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + QByteArray localMsg = msg.toLocal8Bit(); + switch (type) { + case QtDebugMsg: + Sink::Log::debugStream(Sink::Log::DebugLevel::Trace, context.line, context.file, context.function, context.category) << msg; + break; + case QtInfoMsg: + Sink::Log::debugStream(Sink::Log::DebugLevel::Log, context.line, context.file, context.function, context.category) << msg; + break; + case QtWarningMsg: + Sink::Log::debugStream(Sink::Log::DebugLevel::Warning, context.line, context.file, context.function, context.category) << msg; + break; + case QtCriticalMsg: + Sink::Log::debugStream(Sink::Log::DebugLevel::Error, context.line, context.file, context.function, context.category) << msg; + break; + case QtFatalMsg: + Sink::Log::debugStream(Sink::Log::DebugLevel::Error, context.line, context.file, context.function, context.category) << msg; + abort(); + } +} + + int main(int argc, char *argv[]) { const bool gdbDebugMode = qEnvironmentVariableIsSet("SINK_GDB_DEBUG"); @@ -147,6 +174,8 @@ int main(int argc, char *argv[]) std::set_terminate(terminateHandler); } + qInstallMessageHandler(qtMessageHandler); + QCoreApplication app(argc, argv); app.setQuitLockEnabled(false); -- cgit v1.2.3