1 // Baulk - Common - Baulk Console Output Handler
3 // Baulk - Copyright (C) 2008 - Jacob Alexander
5 // Baulk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version, including version 3 of the License.
10 // Baulk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <QStringList>
30 //! Handles all messages sent by the application
33 * - QDebug only sends messages into Baulk
34 * - QWarning only sends messages into Baulk
35 * - QCritical sends messages both to Standard Out and into Baulk
36 * - QFatal sends messages both to Standard Out and into Baulk
37 * however, if a QFatal message occurs the application has usually closed
40 * All other executables (ie. InformationServer)
41 * - All messages currently go to Standout Out
43 void handler( QtMsgType type
, const char *msg
) {
45 QString logPlain
= "";
46 QString css
= "<style type=\"text/css\">"
61 log
= QObject::tr("%1<font color=\"green\"><Debug> %2<br></font>")
64 .replace( QRegExp("\t(.*)\n"), QString("<li>\\1</li>") )
65 .replace( QRegExp("\t(.*)"), QString("<li>\\1</li>") )
68 logPlain
= QObject::tr("\033[22;32m<Debug>\033[22;0m %1").arg( msg
);
69 std::cerr
<< logPlain
.toUtf8().data() << std::endl
;
73 log
= QObject::tr( "%1<font color=\"orange\"><Warning> %2<br></font>")
76 .replace( QRegExp("\t(.*)\n"), QString("<li>\\1</li>") )
77 .replace( QRegExp("\t(.*)"), QString("<li>\\1</li>") )
80 logPlain
= QObject::tr("\033[22;36m<Warning>\033[22;0m %1").arg( msg
);
81 std::cerr
<< logPlain
.toUtf8().data() << std::endl
;
85 log
= QObject::tr("%1<font color=\"red\"><Critical> %2<br></font>")
88 .replace( QRegExp("\t(.*)\n"), QString("<li>\\1</li>") )
89 .replace( QRegExp("\t(.*)"), QString("<li>\\1</li>") )
91 logPlain
= QObject::tr("\033[22;33m<Critical>\033[22;0m %1").arg( msg
);
92 std::cerr
<< logPlain
.toUtf8().data() << std::endl
;
95 log
= QObject::tr("%1<font color=\"red\" font-size=\"large\"><Fatal> %2<br></font>")
98 .replace( QRegExp("\t(.*)\n"), QString("<li>\\1</li>") )
99 .replace( QRegExp("\t(.*)"), QString("<li>\\1</li>") )
101 logPlain
= QObject::tr("\033[22;31m<Fatal>\033[22;0m %1").arg( msg
);
102 std::cerr
<< logPlain
.toUtf8().data() << std::endl
;
110 if ( baulk
->updateMsgLogs( msgLogs
) )