feat: Add delete policy in recon page and system operation log.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "SystemOperationLog.h"
|
||||
|
||||
#include "appvals/AppGlobalValues.h"
|
||||
#include "json/jsonobject.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
@@ -63,3 +64,23 @@ void SystemOperationLog::log(const QString &aOperationText, const QDateTime& aOp
|
||||
reloadFile();
|
||||
mStreamOut << aOperationDate.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<aOperationText<<endl;
|
||||
}
|
||||
|
||||
void SystemOperationLog::cleanHistoryLog()
|
||||
{
|
||||
int expireDays = JsonObject::Instance()->getOperationLogExpireDays();
|
||||
QDateTime currentDate = QDateTime::currentDateTime();
|
||||
QDateTime deleteDate = currentDate.addDays(-expireDays);
|
||||
|
||||
QDir dir(LOG_DIR);
|
||||
QStringList logFiles = dir.entryList(QStringList() << "*.log", QDir::Files);
|
||||
for(const QString &logFile : logFiles)
|
||||
{
|
||||
QString filePath = LOG_DIR + "/" + logFile;
|
||||
QFileInfo fileInfo(filePath);
|
||||
QDateTime fileDate = fileInfo.created();
|
||||
if (fileDate <= deleteDate)
|
||||
{
|
||||
QFile::remove(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
SystemOperationLog();
|
||||
~SystemOperationLog();
|
||||
void reloadFile();
|
||||
static void cleanHistoryLog();
|
||||
|
||||
public slots:
|
||||
void log(const QString& aOperationText, const QDateTime& aOperationDate);
|
||||
|
||||
Reference in New Issue
Block a user