diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-23 16:59:14 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-23 16:59:14 +0100 |
commit | 7a5e24216d9ab827890ca0c0ddb045ad61c328b3 (patch) | |
tree | 42e8523cfd3deec284e5d10d71c07fa68149c628 /synchronizer/main.cpp | |
parent | f7c0869355db935583f1eab66a9d98d378f5c091 (diff) | |
download | sink-7a5e24216d9ab827890ca0c0ddb045ad61c328b3.tar.gz sink-7a5e24216d9ab827890ca0c0ddb045ad61c328b3.zip |
Feed qt debug messages into the same stream as the rest.
Diffstat (limited to 'synchronizer/main.cpp')
-rw-r--r-- | synchronizer/main.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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() | |||
134 | std::abort(); | 134 | std::abort(); |
135 | } | 135 | } |
136 | 136 | ||
137 | /* | ||
138 | * We capture all qt debug messages in the same process and feed it into the sink debug system. | ||
139 | * This way we get e.g. kimap debug messages as well together with the rest. | ||
140 | */ | ||
141 | void qtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) | ||
142 | { | ||
143 | QByteArray localMsg = msg.toLocal8Bit(); | ||
144 | switch (type) { | ||
145 | case QtDebugMsg: | ||
146 | Sink::Log::debugStream(Sink::Log::DebugLevel::Trace, context.line, context.file, context.function, context.category) << msg; | ||
147 | break; | ||
148 | case QtInfoMsg: | ||
149 | Sink::Log::debugStream(Sink::Log::DebugLevel::Log, context.line, context.file, context.function, context.category) << msg; | ||
150 | break; | ||
151 | case QtWarningMsg: | ||
152 | Sink::Log::debugStream(Sink::Log::DebugLevel::Warning, context.line, context.file, context.function, context.category) << msg; | ||
153 | break; | ||
154 | case QtCriticalMsg: | ||
155 | Sink::Log::debugStream(Sink::Log::DebugLevel::Error, context.line, context.file, context.function, context.category) << msg; | ||
156 | break; | ||
157 | case QtFatalMsg: | ||
158 | Sink::Log::debugStream(Sink::Log::DebugLevel::Error, context.line, context.file, context.function, context.category) << msg; | ||
159 | abort(); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | |||
137 | int main(int argc, char *argv[]) | 164 | int main(int argc, char *argv[]) |
138 | { | 165 | { |
139 | const bool gdbDebugMode = qEnvironmentVariableIsSet("SINK_GDB_DEBUG"); | 166 | const bool gdbDebugMode = qEnvironmentVariableIsSet("SINK_GDB_DEBUG"); |
@@ -147,6 +174,8 @@ int main(int argc, char *argv[]) | |||
147 | std::set_terminate(terminateHandler); | 174 | std::set_terminate(terminateHandler); |
148 | } | 175 | } |
149 | 176 | ||
177 | qInstallMessageHandler(qtMessageHandler); | ||
178 | |||
150 | QCoreApplication app(argc, argv); | 179 | QCoreApplication app(argc, argv); |
151 | app.setQuitLockEnabled(false); | 180 | app.setQuitLockEnabled(false); |
152 | 181 | ||