mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Remove max log age for rolling interface log
This commit is contained in:
parent
73cea112ee
commit
b29984ab2c
1 changed files with 1 additions and 7 deletions
|
@ -36,7 +36,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
const FileLogger& _logger;
|
const FileLogger& _logger;
|
||||||
QMutex _fileMutex;
|
QMutex _fileMutex;
|
||||||
std::chrono::system_clock::time_point _lastRollTime;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const QString FILENAME_FORMAT = "hifi-log_%1%2.txt";
|
static const QString FILENAME_FORMAT = "hifi-log_%1%2.txt";
|
||||||
|
@ -52,7 +51,6 @@ static QUuid SESSION_ID;
|
||||||
static const qint64 MAX_LOG_SIZE = 512 * 1024;
|
static const qint64 MAX_LOG_SIZE = 512 * 1024;
|
||||||
// Max log files found in the log directory is 100.
|
// Max log files found in the log directory is 100.
|
||||||
static const qint64 MAX_LOG_DIR_SIZE = 512 * 1024 * 100;
|
static const qint64 MAX_LOG_DIR_SIZE = 512 * 1024 * 100;
|
||||||
static const std::chrono::minutes MAX_LOG_AGE { 60 };
|
|
||||||
|
|
||||||
static FilePersistThread* _persistThreadInstance;
|
static FilePersistThread* _persistThreadInstance;
|
||||||
|
|
||||||
|
@ -83,12 +81,10 @@ FilePersistThread::FilePersistThread(const FileLogger& logger) : _logger(logger)
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
rollFileIfNecessary(file, false);
|
rollFileIfNecessary(file, false);
|
||||||
}
|
}
|
||||||
_lastRollTime = std::chrono::system_clock::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) {
|
void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) {
|
||||||
auto now = std::chrono::system_clock::now();
|
if (file.size() > MAX_LOG_SIZE) {
|
||||||
if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE) {
|
|
||||||
QString newFileName = getLogRollerFilename();
|
QString newFileName = getLogRollerFilename();
|
||||||
if (file.copy(newFileName)) {
|
if (file.copy(newFileName)) {
|
||||||
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||||
|
@ -97,8 +93,6 @@ void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfR
|
||||||
if (notifyListenersIfRolled) {
|
if (notifyListenersIfRolled) {
|
||||||
emit rollingLogFile(newFileName);
|
emit rollingLogFile(newFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastRollTime = std::chrono::system_clock::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir logDir(FileUtils::standardPath(LOGS_DIRECTORY));
|
QDir logDir(FileUtils::standardPath(LOGS_DIRECTORY));
|
||||||
|
|
Loading…
Reference in a new issue