51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
#include "LAMPDataProcessEXE.h"
|
|
#include <QtWidgets/QApplication>
|
|
#include <QCoreApplication>
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <QDateTime>
|
|
#include "LAMPMainWidgetRunProgram.h"
|
|
|
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
// ×Ô¶¨ÒåÏûÏ¢´¦ÀíÆ÷º¯Êý
|
|
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);
|
|
RasterMainWidgetRun();
|
|
return a.exec();
|
|
}
|