Added Qt error message redirect to PWE's log

This commit is contained in:
parax0 2016-01-29 21:43:22 -07:00
parent bb7ec84397
commit 61769fefe2

View File

@ -2,8 +2,24 @@
#include "CDarkStyle.h" #include "CDarkStyle.h"
#include <Core/Resource/Factory/CTemplateLoader.h> #include <Core/Resource/Factory/CTemplateLoader.h>
#include <iostream>
#include <QApplication> #include <QApplication>
#include <QStyleFactory> #include <QStyleFactory>
#include <QtGlobal>
// Redirect qDebug output to the log file
void QtLogRedirect(QtMsgType Type, const QMessageLogContext& /*rkContext*/, const QString& rkMessage)
{
switch (Type)
{
case QtDebugMsg: Log::Write(TString("Qt Debug: ") + TO_TSTRING(rkMessage)); break;
case QtWarningMsg: Log::Write(TString("Qt Warning: ") + TO_TSTRING(rkMessage)); break;
case QtCriticalMsg: Log::Write(TString("Qt Critical: ") + TO_TSTRING(rkMessage)); break;
case QtFatalMsg: Log::Write(TString("Qt Fatal: ") + TO_TSTRING(rkMessage)); break;
}
std::cout << TO_TSTRING(rkMessage) << "\n";
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -13,6 +29,9 @@ int main(int argc, char *argv[])
CStartWindow w; CStartWindow w;
w.show(); w.show();
// Set up debug redirect
qInstallMessageHandler(QtLogRedirect);
// Load templates // Load templates
CTemplateLoader::LoadGameList(); CTemplateLoader::LoadGameList();