Delete local reports older than 30 days.
--HG-- branch : develop
This commit is contained in:
parent
eee931def0
commit
6ded3d1c2b
|
@ -49,6 +49,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QLockFile>
|
#include <QLockFile>
|
||||||
|
#include <QtXmlPatterns>
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(vApp, "v.application")
|
Q_LOGGING_CATEGORY(vApp, "v.application")
|
||||||
|
|
||||||
|
@ -2089,6 +2090,9 @@ void VApplication::StartLogging()
|
||||||
CreateLogDir();
|
CreateLogDir();
|
||||||
BeginLogging();
|
BeginLogging();
|
||||||
ClearOldLogs();
|
ClearOldLogs();
|
||||||
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
ClearOldReports();
|
||||||
|
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2098,6 +2102,34 @@ QTextStream *VApplication::LogFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VApplication::ClearOldReports() const
|
||||||
|
{
|
||||||
|
const QString reportsDir = QString("%1/reports").arg(qApp->applicationDirPath());
|
||||||
|
QDir reports(reportsDir);
|
||||||
|
if (reports.exists())
|
||||||
|
{
|
||||||
|
QStringList filters{"*.log", "*.RPT"};
|
||||||
|
QDir logsDir(reportsDir);
|
||||||
|
logsDir.setNameFilters(filters);
|
||||||
|
logsDir.setCurrent(reportsDir);
|
||||||
|
|
||||||
|
const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
|
||||||
|
if (allFiles.isEmpty() == false)
|
||||||
|
{
|
||||||
|
const QDateTime now = QDateTime::currentDateTime();
|
||||||
|
for (int i = 0; i < allFiles.size(); ++i)
|
||||||
|
{
|
||||||
|
QFileInfo info(allFiles.at(i));
|
||||||
|
if (info.created().daysTo(now) > 30)
|
||||||
|
{
|
||||||
|
QFile(allFiles.at(i)).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// Catch exception and create report. Use if program build with Mingw compiler.
|
// Catch exception and create report. Use if program build with Mingw compiler.
|
||||||
// See more about catcher https://github.com/jrfonseca/drmingw/blob/master/README.md
|
// See more about catcher https://github.com/jrfonseca/drmingw/blob/master/README.md
|
||||||
|
|
|
@ -107,9 +107,11 @@ public:
|
||||||
static QStringList LabelLanguages();
|
static QStringList LabelLanguages();
|
||||||
QString STDescription(const QString &id)const;
|
QString STDescription(const QString &id)const;
|
||||||
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
||||||
|
|
||||||
void StartLogging();
|
void StartLogging();
|
||||||
QTextStream *LogFile();
|
QTextStream *LogFile();
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
static void DrMingw();
|
static void DrMingw();
|
||||||
void CollectReports() const;
|
void CollectReports() const;
|
||||||
|
@ -180,6 +182,7 @@ private:
|
||||||
void CollectReport(const QString &reportName) const;
|
void CollectReport(const QString &reportName) const;
|
||||||
void SendReport(const QString &reportName) const;
|
void SendReport(const QString &reportName) const;
|
||||||
QString ReadFileForSending(QFile &file)const;
|
QString ReadFileForSending(QFile &file)const;
|
||||||
|
void ClearOldReports()const;
|
||||||
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
|
||||||
QString LogDirPath()const;
|
QString LogDirPath()const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user