2025-02-06 13:18:25 +00:00
|
|
|
|
#include "LAMPDataProcessEXE.h"
|
|
|
|
|
#include <QtWidgets/QApplication>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QDateTime>
|
2025-02-09 18:16:07 +00:00
|
|
|
|
#include "LAMPMainWidgetRunProgram.h"
|
2025-02-17 07:03:09 +00:00
|
|
|
|
#include "RasterWidgetMessageShow.h"
|
2025-02-06 13:18:25 +00:00
|
|
|
|
|
2025-02-09 18:16:07 +00:00
|
|
|
|
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
|
2025-02-06 13:18:25 +00:00
|
|
|
|
// <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);
|
2025-02-17 07:03:09 +00:00
|
|
|
|
|
|
|
|
|
RasterMessageShow::RasterWidgetMessageShow* _showIntance = RasterMessageShow::RasterWidgetMessageShow::getInstance();
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case QtDebugMsg:
|
|
|
|
|
{
|
2025-02-19 07:06:59 +00:00
|
|
|
|
QString logMessage = QString("%1 Debug: %2 (%3:%4, %5)")
|
2025-02-17 07:03:09 +00:00
|
|
|
|
.arg(dateTime) // Assuming dateTime is a QDateTime object and needs to be converted to string
|
|
|
|
|
.arg(QString::fromLocal8Bit(localMsg.constData()))
|
|
|
|
|
.arg(file)
|
|
|
|
|
.arg(context.line)
|
|
|
|
|
.arg(function);
|
2025-02-19 08:26:55 +00:00
|
|
|
|
ts << logMessage << "\n";
|
2025-02-17 07:03:09 +00:00
|
|
|
|
_showIntance->ShowMessageInfo(logMessage);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QtInfoMsg:
|
|
|
|
|
{
|
2025-02-19 07:06:59 +00:00
|
|
|
|
QString logMessage = QString("%1 Info: %2 (%3:%4, %5)")
|
2025-02-17 07:03:09 +00:00
|
|
|
|
.arg(dateTime)
|
|
|
|
|
.arg(QString::fromLocal8Bit(localMsg.constData()))
|
|
|
|
|
.arg(file)
|
|
|
|
|
.arg(context.line)
|
|
|
|
|
.arg(function);
|
2025-02-19 08:26:55 +00:00
|
|
|
|
ts << logMessage << "\n";
|
2025-02-17 07:03:09 +00:00
|
|
|
|
_showIntance->ShowMessageInfo(logMessage);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QtWarningMsg:
|
|
|
|
|
{
|
2025-02-19 07:06:59 +00:00
|
|
|
|
QString logMessage = QString("%1 Warning: %2 (%3:%4, %5)")
|
2025-02-17 07:03:09 +00:00
|
|
|
|
.arg(dateTime)
|
|
|
|
|
.arg(QString::fromLocal8Bit(localMsg.constData()))
|
|
|
|
|
.arg(file)
|
|
|
|
|
.arg(context.line)
|
|
|
|
|
.arg(function);
|
2025-02-19 08:26:55 +00:00
|
|
|
|
ts << logMessage << "\n";
|
2025-02-17 07:03:09 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QtCriticalMsg:
|
|
|
|
|
{
|
2025-02-19 07:06:59 +00:00
|
|
|
|
QString logMessage = QString("%1 Critical: %2 (%3:%4, %5)")
|
2025-02-17 07:03:09 +00:00
|
|
|
|
.arg(dateTime)
|
|
|
|
|
.arg(QString::fromLocal8Bit(localMsg.constData()))
|
|
|
|
|
.arg(file)
|
|
|
|
|
.arg(context.line)
|
|
|
|
|
.arg(function);
|
2025-02-19 08:26:55 +00:00
|
|
|
|
ts << logMessage << "\n";
|
2025-02-17 07:03:09 +00:00
|
|
|
|
_showIntance->ShowMessageInfo(logMessage);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QtFatalMsg:
|
|
|
|
|
{
|
2025-02-19 07:06:59 +00:00
|
|
|
|
QString logMessage = QString("%1 Fatal: %2 (%3:%4, %5)")
|
2025-02-17 07:03:09 +00:00
|
|
|
|
.arg(dateTime)
|
|
|
|
|
.arg(QString::fromLocal8Bit(localMsg.constData()))
|
|
|
|
|
.arg(file)
|
|
|
|
|
.arg(context.line)
|
|
|
|
|
.arg(function);
|
2025-02-19 08:26:55 +00:00
|
|
|
|
ts << logMessage<<"\n";
|
2025-02-17 07:03:09 +00:00
|
|
|
|
_showIntance->ShowMessageInfo(logMessage);
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-02-06 13:18:25 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2025-02-17 07:03:09 +00:00
|
|
|
|
qInstallMessageHandler(customMessageHandler);
|
2025-02-06 13:18:25 +00:00
|
|
|
|
QApplication a(argc, argv);
|
2025-02-09 18:16:07 +00:00
|
|
|
|
RasterMainWidgetRun();
|
2025-02-06 13:18:25 +00:00
|
|
|
|
return a.exec();
|
|
|
|
|
}
|