Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
CamiTKQTestMessageHandler.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#include <QMessageLogContext>
27#include <QString>
28#include <iostream>
29
30// Use
31// qInstallMessageHandler(camitkQTestMessageHandler);
32// in initTestCase() slot to use this specific handler of qDebug() macros
33
34void camitkQTestMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) {
35 QByteArray localMsg = msg.toLocal8Bit();
36 const char* file = context.file ? context.file : "";
37 const char* function = context.function ? context.function : "";
38 switch (type) {
39 case QtDebugMsg:
40 std::cerr << "Debug: " << localMsg.constData() << " (" << file << ":" << function << ")" << std::endl;
41 break;
42 case QtInfoMsg:
43 std::cerr << "Info: " << localMsg.constData() << " (" << file << ":" << function << ")" << std::endl;
44 break;
45 case QtWarningMsg:
46 std::cerr << "Warning: " << localMsg.constData() << " (" << file << ":" << function << ")" << std::endl;
47 break;
48 case QtCriticalMsg:
49 std::cerr << "Critical: " << localMsg.constData() << " (" << file << ":" << function << ")" << std::endl;
50 break;
51 case QtFatalMsg:
52 std::cerr << "Fatal: " << localMsg.constData() << " (" << file << ":" << function << ")" << std::endl;
53 abort();
54 }
55}
void camitkQTestMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
Definition CamiTKQTestMessageHandler.h:34