49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
|
#include "LAMPDataProcessEXE.h"
|
|||
|
#include <QtWidgets/QApplication>
|
|||
|
#include <QCoreApplication>
|
|||
|
#include <QDebug>
|
|||
|
#include <QFile>
|
|||
|
#include <QTextStream>
|
|||
|
#include <QDateTime>
|
|||
|
#include "RasterProcessTool.h"
|
|||
|
|
|||
|
|
|||
|
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
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);
|
|||
|
RasterProcessTool w;
|
|||
|
w.show();
|
|||
|
return a.exec();
|
|||
|
}
|