MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / MessageHandler

Function MessageHandler

app/src/Misc/ModuleManager.cpp:140–211  ·  view source on GitHub ↗

* @brief Custom message handler for Qt debug, warning, critical, and fatal messages. */

Source from the content-addressed store, hash-verified

138 * @brief Custom message handler for Qt debug, warning, critical, and fatal messages.
139 */
140static void MessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
141{
142 (void)context;
143 if (msg.isEmpty())
144 return;
145
146 if (type == QtInfoMsg && msg.startsWith("OpenType support missing"))
147 return;
148
149 if (type == QtWarningMsg) {
150 if (msg.startsWith("Qt was built without Direct3D 12 support"))
151 return;
152
153 if (msg.contains("setGeometry"))
154 return;
155
156 if (msg.contains("The following paths were searched for Qt WebEngine locales"))
157 return;
158
159 if (msg.contains("attempting to set invalid range for value axis:"))
160 return;
161
162 if (msg.contains("Invalid path data; path truncated."))
163 return;
164
165 if (msg.contains("QSocketNotifier::Exception is not supported on iOS"))
166 return;
167
168 if (msg.contains("QQmlVMEMetaObject: Internal error"))
169 return;
170
171 if (msg.startsWith("QThread::start: Failed to set thread priority"))
172 return;
173 }
174
175 QString message;
176 if (context.function)
177 message = QStringLiteral("%1 - %2").arg(context.function, msg);
178 else
179 message = msg;
180
181 const bool useAnsiColors = Console::Handler::instance().ansiColorsEnabled();
182 const QString output = Widgets::Terminal::formatDebugMessage(type, message, useAnsiColors);
183 if (output.isEmpty())
184 return;
185
186 // code-verify off
187 std::cout << Widgets::Terminal::formatDebugMessage(type, message, false).toStdString()
188 << std::endl;
189 // code-verify on
190
191 Console::Handler::instance().displayDebugData(output + "\n");
192
193 const bool isCritical = (type == QtCriticalMsg || type == QtFatalMsg);
194 const bool isWarning = (type == QtWarningMsg);
195 if (!isCritical && !isWarning)
196 return;
197

Callers

nothing calls this directly

Calls 6

isEmptyMethod · 0.80
ansiColorsEnabledMethod · 0.80
displayDebugDataMethod · 0.80
containsMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected