RasterProcessTool/LAMPSARProcessProgram/main.cpp

56 lines
1.8 KiB
C++

#include "RasterProcessTool.h"
#include <QtWidgets/QApplication>
#include "RegisterToolbox.h"
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include <QDateTime>
// 自定义消息处理器函数
void customMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
QByteArray localMsg = msg.toLocal8Bit();
const char* file = context.file ? context.file : "";
const char* function = context.function ? context.function : "";
QString dateTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz");
QFile outFile("application.log");
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream ts(&outFile);
switch (type) {
case QtDebugMsg:
ts << dateTime << " Debug: " << localMsg.constData() << " (" << file << ":" << context.line << ", " << function << ")\n";
break;
case QtInfoMsg:
ts << dateTime << " Info: " << localMsg.constData() << " (" << file << ":" << context.line << ", " << function << ")\n";
break;
case QtWarningMsg:
ts << dateTime << " Warning: " << localMsg.constData() << " (" << file << ":" << context.line << ", " << function << ")\n";
break;
case QtCriticalMsg:
ts << dateTime << " Critical: " << localMsg.constData() << " (" << file << ":" << context.line << ", " << function << ")\n";
break;
case QtFatalMsg:
ts << dateTime << " Fatal: " << localMsg.constData() << " (" << file << ":" << context.line << ", " << function << ")\n" ;
abort();
}
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//qInstallMessageHandler(customMessageHandler);
RasterProcessTool* w=new RasterProcessTool;// 主界面
RegisterPreToolBox(w);
w->show();
return a.exec();
}