feat: Make log writing in other thread.
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
"lockscreen": "0",
|
"lockscreen": "0",
|
||||||
"CompleteNotify": true,
|
"CompleteNotify": true,
|
||||||
"ScanConfirm": false,
|
"ScanConfirm": false,
|
||||||
"AnonymousMode": false
|
"AnonymousMode": false,
|
||||||
},
|
},
|
||||||
"protocol": {
|
"protocol": {
|
||||||
"default": "0",
|
"default": "0",
|
||||||
@@ -101,8 +101,8 @@
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"worklistfilter": {
|
"worklistfilter": {
|
||||||
"default": "Recent3Days",
|
"modality": "US",
|
||||||
"lists": "Today;Recent3Days;ThisWeek;ThisMonth"
|
"date": "0"
|
||||||
},
|
},
|
||||||
"screensaver": {
|
"screensaver": {
|
||||||
"open": false,
|
"open": false,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "DmsAsyncAction.h"
|
#include "DmsAsyncAction.h"
|
||||||
#include "dms_mq.h"
|
#include "dms_mq.h"
|
||||||
|
#include "log/LogManager.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -17,7 +18,6 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
|
|||||||
, mResponseSignal(aResponseSignal)
|
, mResponseSignal(aResponseSignal)
|
||||||
, mSendData()
|
, mSendData()
|
||||||
, mIsResponsed(false)
|
, mIsResponsed(false)
|
||||||
, mIsRunning(false)
|
|
||||||
{
|
{
|
||||||
mTimer->setSingleShot(true);
|
mTimer->setSingleShot(true);
|
||||||
mTimer->setInterval(TIMEOUT_MSEC);
|
mTimer->setInterval(TIMEOUT_MSEC);
|
||||||
@@ -45,6 +45,7 @@ bool DmsAsyncAction::execute()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Message:%3").arg(mServerId).arg(mActionId).arg(mSendData));
|
||||||
mTimer->start();
|
mTimer->start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ private:
|
|||||||
QString mResponseSignal;
|
QString mResponseSignal;
|
||||||
QString mSendData;
|
QString mSendData;
|
||||||
bool mIsResponsed;
|
bool mIsResponsed;
|
||||||
bool mIsRunning;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DMSASYNCACTION_H
|
#endif // DMSASYNCACTION_H
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ DmsSyncAction::DmsSyncAction(int aServerId, int aActionId, QObject* aObject, con
|
|||||||
{
|
{
|
||||||
mTimer->setSingleShot(true);
|
mTimer->setSingleShot(true);
|
||||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
connect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
||||||
|
connect(mObject, ("2" + mSignal).toStdString().c_str(), mTimer, SLOT(stop()));
|
||||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
connect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
||||||
connect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
connect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
||||||
}
|
}
|
||||||
@@ -49,6 +50,7 @@ DmsSyncActionResult DmsSyncAction::execute()
|
|||||||
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Message:%3").arg(mServerId).arg(mActionId).arg(mSendData));
|
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Message:%3").arg(mServerId).arg(mActionId).arg(mSendData));
|
||||||
if(!waitUntilSignalReceived())
|
if(!waitUntilSignalReceived())
|
||||||
{
|
{
|
||||||
|
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Time out.").arg(mServerId).arg(mActionId));
|
||||||
DmsSyncActionResult result(false, "time out");
|
DmsSyncActionResult result(false, "time out");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ LogManager::~LogManager()
|
|||||||
|
|
||||||
void LogManager::writeSystemOperationLog(const QString& aMessage)
|
void LogManager::writeSystemOperationLog(const QString& aMessage)
|
||||||
{
|
{
|
||||||
emit doWriteSystemOperationLog(aMessage);
|
emit doWriteSystemOperationLog(aMessage, QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogManager::writeUserOperationLog(const QString& aMessage)
|
void LogManager::writeUserOperationLog(const QString& aMessage)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
QString getCurrentUserOperationLogFile();
|
QString getCurrentUserOperationLogFile();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void doWriteSystemOperationLog(const QString& aMessage);
|
void doWriteSystemOperationLog(const QString& aMessage, const QDateTime& aOperationDate);
|
||||||
void doWriteUserOperationLog(const QString& aMessage);
|
void doWriteUserOperationLog(const QString& aMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ SystemOperationLog::~SystemOperationLog()
|
|||||||
void SystemOperationLog::reloadFile()
|
void SystemOperationLog::reloadFile()
|
||||||
{
|
{
|
||||||
QString newFileName = LOG_DIR + QDate::currentDate().toString("/yyyy-MM-dd") + SYS_LOG_SUFFIX;
|
QString newFileName = LOG_DIR + QDate::currentDate().toString("/yyyy-MM-dd") + SYS_LOG_SUFFIX;
|
||||||
if (newFileName == mCurrentFileName && !AppGlobalValues::InProcessing().toBool()) return;
|
if (newFileName == mCurrentFileName) return;
|
||||||
mLogFile.close();
|
mLogFile.close();
|
||||||
mLogFile.setFileName(newFileName);
|
mLogFile.setFileName(newFileName);
|
||||||
if (mLogFile.exists())
|
if (mLogFile.exists())
|
||||||
@@ -58,9 +58,8 @@ void SystemOperationLog::reloadFile()
|
|||||||
mStreamOut.setDevice(&mLogFile);
|
mStreamOut.setDevice(&mLogFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemOperationLog::log(const QString &aOperationText)
|
void SystemOperationLog::log(const QString &aOperationText, const QDateTime& aOperationDate)
|
||||||
{
|
{
|
||||||
reloadFile();
|
reloadFile();
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
mStreamOut << aOperationDate.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<aOperationText<<endl;
|
||||||
mStreamOut << now.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<aOperationText<<endl;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
void reloadFile();
|
void reloadFile();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void log(const QString& aOperationText);
|
void log(const QString& aOperationText, const QDateTime& aOperationDate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mCurrentFileName;
|
QString mCurrentFileName;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void UserOperationLog::log(const QString& aOperationText)
|
|||||||
void UserOperationLog::reloadFile() {
|
void UserOperationLog::reloadFile() {
|
||||||
QString newFileName = logDir + QDate::currentDate().toString("/yyyy-MM-dd")+QString("-op.log");
|
QString newFileName = logDir + QDate::currentDate().toString("/yyyy-MM-dd")+QString("-op.log");
|
||||||
//inprocessing 暂时没有使用
|
//inprocessing 暂时没有使用
|
||||||
if (newFileName == currentFileName && !AppGlobalValues::InProcessing().toBool()) return;
|
if (newFileName == currentFileName) return;
|
||||||
logFile.close();
|
logFile.close();
|
||||||
logFile.setFileName(newFileName);
|
logFile.setFileName(newFileName);
|
||||||
if (logFile.exists())
|
if (logFile.exists())
|
||||||
|
|||||||
Reference in New Issue
Block a user