Index: sources/storage/Logger.cpp =================================================================== diff -u -r3a528c6f3fce8132de2791b55d3227e715d68898 -r7ebc073150532073ae7f1a0e768272bcff5d6fb3 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 3a528c6f3fce8132de2791b55d3227e715d68898) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 7ebc073150532073ae7f1a0e768272bcff5d6fb3) @@ -335,7 +335,7 @@ int result = 0; static QString mOSource; QString mDestination = USB_Mount_Point; - for ( const auto &iType : { eLogEvent, eLogDatum /*, eLogDebug*/ } ) { + for ( const auto &iType : { eLogEvent, eLogDatum } ) { QString mCSource = _logPathNames[iType]; // if the event and datum are mixed (mOSource == mCSource) in one file then no need to go over the same files in same folder and do it again. if (mOSource != mCSource) { @@ -349,31 +349,113 @@ } /*! + * \brief Logger::exportService + * \details Exports the service files from service folder (Storage::Log_Base_Path_Name_Location) + * into USB drive folder (Storage::USB_Mount_Point) + * \return true if at least one file has been exported + */ +bool Logger::exportErrs() +{ + // qDebug() << " ~~~~~~~~~~ " << QThread::currentThread()->objectName(); + int result = 0; + QString mDestination = USB_Mount_Point; + QString mSource = _logPathNames[eLogDebug]; + // Copy Folder + result = FileHandler::copyFolder( mSource, mDestination); + return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. +} + +/*! + * \brief Logger::exportTreatment + * \details Exports the treatment files from treatment folder (Storage::Log_Base_Path_Name_Location) + * into USB drive folder (Storage::USB_Mount_Point) + * \return true if at least one file has been exported + */ +bool Logger::exportTrts() +{ + // qDebug() << " ~~~~~~~~~~ " << QThread::currentThread()->objectName(); + int result = 0; + QString mDestination = USB_Mount_Point; + QString mSource = _logPathNames[eLogTrtmt]; + // Copy Folder + result = FileHandler::copyFolder( mSource, mDestination); + return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. +} + +/*! + * \brief Logger::concurrentExportTest + * \details Tests if a log is running + * \return if running return false + */ +bool Logger::concurrentExportIsOk() +{ + if ( _exportLogsWatcher.isRunning() ) { + LOG_DEBUG(QString("Export type of %1 is running").arg(_logNames[_exportLogsType])); + return false; + } + return true; +} + +/*! * \brief Logger::concurrentExportLogs * \details Export logs scheduler. * \return always returns true for now. * \note This method uses QtConcurrent run to execute the FileHandler copyFolder method. */ bool Logger::concurrentExportLogs() { - // disabled coco begin validated: This needs user interaction to export to USB device - // has been tested manually - LOG_DEBUG("Export Logs Start"); - QFuture future = QtConcurrent::run(this, &Logger::exportLogs); + if ( ! concurrentExportIsOk() ) return false; + + _exportLogsType = eLogEvent; + LOG_DEBUG(QString("Export %1 start").arg(_logNames[_exportLogsType])); + QFuture future = QtConcurrent::run(this, &Logger::exportLogs); _exportLogsWatcher.setFuture(future); return true; } -// disabled coco end /*! + * \brief Logger::concurrentExportLogs + * \details Export logs scheduler. + * \return always returns true for now. + * \note This method uses QtConcurrent run to execute the FileHandler copyFolder method. + */ +bool Logger::concurrentExportErrs() +{ + if ( ! concurrentExportIsOk() ) return false; + + _exportLogsType = eLogDebug; + LOG_DEBUG(QString("Export %1 start").arg(_logNames[_exportLogsType])); + QFuture future = QtConcurrent::run(this, &Logger::exportErrs); + _exportLogsWatcher.setFuture(future); + return true; +} + +/*! + * \brief Logger::concurrentExportLogs + * \details Export logs scheduler. + * \return always returns true for now. + * \note This method uses QtConcurrent run to execute the FileHandler copyFolder method. + */ +bool Logger::concurrentExportTrts() +{ + if ( ! concurrentExportIsOk() ) return false; + + _exportLogsType = eLogTrtmt; + LOG_DEBUG(QString("Export %1 start").arg(_logNames[_exportLogsType])); + QFuture future = QtConcurrent::run(this, &Logger::exportTrts); + _exportLogsWatcher.setFuture(future); + return true; +} + +/*! * \brief Logger::onExportLogs * \details Export log notification slot which logs result of export. */ void Logger::onExportLogs() { // disabled coco begin validated: This needs user interaction to export to USB device // has been tested manually - LOG_DEBUG(QString("Export Logs Ended: %1").arg(_exportLogsWatcher.result())); + LOG_DEBUG(QString("Export %1 ended: %2").arg(_logNames[_exportLogsType]).arg(_exportLogsWatcher.result())); emit didExportLogs(); } // disabled coco end