- changes to threaded logging so when things get very busy the thread dumps log entries more quickly

This commit is contained in:
Mark Vejvoda 2010-12-25 23:49:24 +00:00
parent b006e72b53
commit 2234928a35
2 changed files with 12 additions and 2 deletions

View File

@ -101,6 +101,7 @@ protected:
time_t lastSaveToDisk;
void saveToDisk();
bool checkSaveCurrentLogBufferToDisk();
public:
LogFileThread();

View File

@ -205,6 +205,16 @@ void LogFileThread::addLogEntry(SystemFlags::DebugType type, string logEntry) {
logList.push_back(entry);
}
bool LogFileThread::checkSaveCurrentLogBufferToDisk() {
bool ret = false;
if(difftime(time(NULL),lastSaveToDisk) >= 5 ||
LogFileThread::getLogEntryBufferCount() >= 35000) {
lastSaveToDisk = time(NULL);
ret = true;
}
return ret;
}
void LogFileThread::execute() {
RunningStatusSafeWrapper runningStatus(this);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -217,8 +227,7 @@ void LogFileThread::execute() {
try {
for(;this->getQuitStatus() == false;) {
if(difftime(time(NULL),lastSaveToDisk) >= 5) {
lastSaveToDisk = time(NULL);
if(checkSaveCurrentLogBufferToDisk() == true) {
saveToDisk();
}
if(this->getQuitStatus() == false) {