Index: sources/storage/Logger.cpp =================================================================== diff -u -raccc25a2cefe436401ad04c57713cfa410621317 -re6ddf6840cdd5a09deaac1dcdcd7d70064dc6a09 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision accc25a2cefe436401ad04c57713cfa410621317) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision e6ddf6840cdd5a09deaac1dcdcd7d70064dc6a09) @@ -155,8 +155,10 @@ connect(&_removeLogsWatcher, SIGNAL(finished ()), this , SLOT(onRemoveLogs())); - connect(&_flushLogsWatcher , SIGNAL(finished ()), - this , SLOT(onFlushLogs())); + connect(&_flushLogsWatcherA, SIGNAL(finished ()), + this , SLOT(onFlushLogsA())); + connect(&_flushLogsWatcherD, SIGNAL(finished ()), + this , SLOT(onFlushLogsD())); connect(&_DeviceController, SIGNAL( didSDCardStateChange(bool, bool)), this , SLOT( onSDCardStateChange(bool, bool))); @@ -321,10 +323,10 @@ _cacheCounter --; } else { - _cacheCounter = _cachetimeout; _cacheIndex = logSwitch(); // switch the index for caching while the flush is working - concurrentFlushLog(eLogAppED); - concurrentFlushLog(eLogDebug); + concurrentFlushLogA(); + concurrentFlushLogD(); + _cacheCounter = _cachetimeout; } } @@ -336,7 +338,7 @@ } } -Logger::CacheIndex Logger::logSwitch() { +int Logger::logSwitch() { return _cacheIndex == eCache1 ? eCache2 : eCache1;; } @@ -367,12 +369,16 @@ case eLogAppED : _cacheA[_cacheIndex] += mContent; break; case eLogDebug : _cacheD[_cacheIndex] += mContent; break; default : _cacheD[_cacheIndex] += QString("Incorrect type of logging %1").arg(vLogType); - _cacheD[_cacheIndex] += mContent; + _cacheD[_cacheIndex] += mContent; break; } if ( logOverflow(vLogType) ) { _cacheIndex = logSwitch(); // switch the index for caching while the flush is working - concurrentFlushLog(vLogType); + switch ( vLogType ) { + case eLogAppED : concurrentFlushLogA(); break; + case eLogDebug : concurrentFlushLogD(); break; + default : concurrentFlushLogD(); break; + } } // console out the log if enabled. @@ -396,7 +402,7 @@ //NOTE: the _cacheIndex has been (has to be) switched for the log to continue while we are in the temp thread to flush the log - CacheIndex cacheIndex = logSwitch(); + QAtomicInt cacheIndex = logSwitch(); QString mContent; QDateTime datetime = QDateTime::currentDateTime(); int count = 0; @@ -498,26 +504,53 @@ * \return always returns true for now. * \note This method uses QtConcurrent to execute the flush method in a separate temp thread. */ -bool Logger::concurrentFlushLog(LogType vLogType) +bool Logger::concurrentFlushLogA() { - emit didFlushLogs(true); - LOG_DEBUG("Flush Logs Starting"); - QFuture mFuture = QtConcurrent::run(this, &Logger::flush, vLogType); - _flushLogsWatcher.setFuture(mFuture); + emit didFlushLogsA(true); + _flushElapsedA.start(); + LOG_DEBUG("Flush app Logs Starting"); + QFuture mFuture = QtConcurrent::run(this, &Logger::flush, LogType::eLogAppED); + _flushLogsWatcherA.setFuture(mFuture); return true; } /*! + * \brief Logger::concurrentFlushLogs + * \details Flushes the log buffer to the file in a separate thread + * \return always returns true for now. + * \note This method uses QtConcurrent to execute the flush method in a separate temp thread. + */ +bool Logger::concurrentFlushLogD() +{ + emit didFlushLogsD(true); + _flushElapsedD.start(); + LOG_DEBUG("Flush err Logs Starting"); + QFuture mFuture = QtConcurrent::run(this, &Logger::flush, LogType::eLogDebug); + _flushLogsWatcherD.setFuture(mFuture); + return true; +} + +/*! * \brief Logger::onRemoveLogs * \details Remove old logs notification slot which logs result of remove. */ -void Logger::onFlushLogs() +void Logger::onFlushLogsA() { - LOG_DEBUG(tr("Flush Logs Ended: %1").arg(_flushLogsWatcher.result())); - emit didFlushLogs(false); + LOG_DEBUG(tr("Flush app Logs Ended: %1,%2").arg(_flushLogsWatcherA.result()).arg(_flushElapsedA.elapsed())); + emit didFlushLogsA(false); } /*! + * \brief Logger::onRemoveLogs + * \details Remove old logs notification slot which logs result of remove. + */ +void Logger::onFlushLogsD() +{ + LOG_DEBUG(tr("Flush err Logs Ended: %1,%2").arg(_flushLogsWatcherD.result()).arg(_flushElapsedD.elapsed())); + emit didFlushLogsD(false); +} + +/*! * \brief Logger::exportLogs * \details Exports the log files from log folder (Storage::Log_Base_Path_Name_Location) * into USB drive folder (Storage::USB_Mount_Point)