mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-14 08:16:03 +02:00
More coding standard fun!
This commit is contained in:
parent
9641ae8cd8
commit
4fb9d8801c
1 changed files with 28 additions and 28 deletions
|
@ -62,37 +62,37 @@ FilePersistThread::FilePersistThread(const FileLogger& logger) : _logger(logger)
|
|||
}
|
||||
|
||||
void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) {
|
||||
uint64_t now = usecTimestampNow();
|
||||
if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE_USECS) {
|
||||
QString newFileName = getLogRollerFilename();
|
||||
if (file.copy(newFileName)) {
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
file.close();
|
||||
qDebug() << "Rolled log file:" << newFileName;
|
||||
uint64_t now = usecTimestampNow();
|
||||
if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE_USECS) {
|
||||
QString newFileName = getLogRollerFilename();
|
||||
if (file.copy(newFileName)) {
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
file.close();
|
||||
qDebug() << "Rolled log file:" << newFileName;
|
||||
|
||||
if (notifyListenersIfRolled) {
|
||||
emit rollingLogFile(newFileName);
|
||||
}
|
||||
if (notifyListenersIfRolled) {
|
||||
emit rollingLogFile(newFileName);
|
||||
}
|
||||
|
||||
_lastRollTime = now;
|
||||
}
|
||||
QStringList nameFilters;
|
||||
nameFilters << FILENAME_WILDCARD;
|
||||
_lastRollTime = now;
|
||||
}
|
||||
QStringList nameFilters;
|
||||
nameFilters << FILENAME_WILDCARD;
|
||||
|
||||
QDir logQDir(FileUtils::standardPath(LOGS_DIRECTORY));
|
||||
logQDir.setNameFilters(nameFilters);
|
||||
logQDir.setSorting(QDir::Time);
|
||||
QFileInfoList filesInDir = logQDir.entryInfoList();
|
||||
qint64 totalSizeOfDir = 0;
|
||||
foreach(QFileInfo dirItm, filesInDir){
|
||||
if (totalSizeOfDir < MAX_LOG_DIR_SIZE){
|
||||
totalSizeOfDir += dirItm.size();
|
||||
} else {
|
||||
QFile file(dirItm.filePath());
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
QDir logQDir(FileUtils::standardPath(LOGS_DIRECTORY));
|
||||
logQDir.setNameFilters(nameFilters);
|
||||
logQDir.setSorting(QDir::Time);
|
||||
QFileInfoList filesInDir = logQDir.entryInfoList();
|
||||
qint64 totalSizeOfDir = 0;
|
||||
foreach(QFileInfo dirItm, filesInDir){
|
||||
if (totalSizeOfDir < MAX_LOG_DIR_SIZE){
|
||||
totalSizeOfDir += dirItm.size();
|
||||
} else {
|
||||
QFile file(dirItm.filePath());
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool FilePersistThread::processQueueItems(const Queue& messages) {
|
||||
QFile file(_logger._fileName);
|
||||
|
|
Loading…
Reference in a new issue