mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
Coding standard fun!
This commit is contained in:
parent
be0446f9a9
commit
9641ae8cd8
1 changed files with 15 additions and 17 deletions
|
@ -62,20 +62,20 @@ FilePersistThread::FilePersistThread(const FileLogger& logger) : _logger(logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) {
|
void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) {
|
||||||
uint64_t now = usecTimestampNow();
|
uint64_t now = usecTimestampNow();
|
||||||
if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE_USECS) {
|
if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE_USECS) {
|
||||||
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);
|
||||||
file.close();
|
file.close();
|
||||||
qDebug() << "Rolled log file:" << newFileName;
|
qDebug() << "Rolled log file:" << newFileName;
|
||||||
|
|
||||||
if (notifyListenersIfRolled) {
|
if (notifyListenersIfRolled) {
|
||||||
emit rollingLogFile(newFileName);
|
emit rollingLogFile(newFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastRollTime = now;
|
_lastRollTime = now;
|
||||||
}
|
}
|
||||||
QStringList nameFilters;
|
QStringList nameFilters;
|
||||||
nameFilters << FILENAME_WILDCARD;
|
nameFilters << FILENAME_WILDCARD;
|
||||||
|
|
||||||
|
@ -84,18 +84,16 @@ void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfR
|
||||||
logQDir.setSorting(QDir::Time);
|
logQDir.setSorting(QDir::Time);
|
||||||
QFileInfoList filesInDir = logQDir.entryInfoList();
|
QFileInfoList filesInDir = logQDir.entryInfoList();
|
||||||
qint64 totalSizeOfDir = 0;
|
qint64 totalSizeOfDir = 0;
|
||||||
foreach (QFileInfo dirItm, filesInDir){
|
foreach(QFileInfo dirItm, filesInDir){
|
||||||
if (totalSizeOfDir < MAX_LOG_DIR_SIZE){
|
if (totalSizeOfDir < MAX_LOG_DIR_SIZE){
|
||||||
totalSizeOfDir += dirItm.size();
|
totalSizeOfDir += dirItm.size();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QFile file(dirItm.filePath());
|
QFile file(dirItm.filePath());
|
||||||
file.remove();
|
file.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FilePersistThread::processQueueItems(const Queue& messages) {
|
bool FilePersistThread::processQueueItems(const Queue& messages) {
|
||||||
QFile file(_logger._fileName);
|
QFile file(_logger._fileName);
|
||||||
rollFileIfNecessary(file);
|
rollFileIfNecessary(file);
|
||||||
|
|
Loading…
Reference in a new issue