Index: sources/storage/Logger.cpp =================================================================== diff -u -r1f5b2250ae70d305654d014a9aa1fd8baa29779c -r2912750c8e787739f2cb2069fee1b33195a9ef54 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 1f5b2250ae70d305654d014a9aa1fd8baa29779c) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 2912750c8e787739f2cb2069fee1b33195a9ef54) @@ -7,7 +7,7 @@ * * \file Logger.cpp * \author (last) Behrouz NematiPour - * \date (last) 15-Oct-2022 + * \date (last) 25-Jul-2023 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * @@ -224,7 +224,7 @@ _dir.setPath(Storage::Standard_tmp); // NOTE: Do not use LOG_XXXXX, At this moment Logger has not been initialized yet QString msg = QString("temp location used for events logging (%1)").arg(_dir.path()); - qDebug() << msg; + //DEBUG qDebug() << msg; FileHandler::errOut(msg); } else { @@ -245,19 +245,27 @@ return ok; } +/*! + * \brief Logger::onCryptSetupMount + * \details the handlet for the _DeviceController::didCryptSetupMount + * to set the treatment fodler when the encrypted parttion is ready + * and successfully decrypted and mounted. + * It checks to make sure the folder exist and is able to be written and read. + */ void Logger::onCryptSetupMount(bool /*vPass*/) { LogType vLogType = LogType::eLogTrtmt; QString basePath = Storage::Settings_Path(); // use the Settings path first (/var/configurations (Encrypted Partition)) - if ( ! QDir (basePath ).exists( )) { basePath = Storage::Standard_tmp; } else { goto lOut; } - if ( ! FileHandler::makeFolder (basePath + Storage::Log_Folder_Treatment )) { basePath = Storage::Standard_tmp; } else { goto lOut; } - if ( ! FileHandler::makeFolder (basePath + Storage::Log_Folder_Pending )) { basePath = Storage::Standard_tmp; } else { goto lOut; } + if ( ! QDir (basePath ).exists( )) { basePath = Storage::Standard_tmp; goto lOut; } + if ( ! FileHandler::makeFolder (basePath + Storage::Log_Folder_Treatment )) { basePath = Storage::Standard_tmp; goto lOut; } lOut: _logPathNames[vLogType] = basePath + Storage::Log_Folder_Treatment; emit didLogPathSet(vLogType, _logPathNames[vLogType]); + + FileHandler::errOut(tr("The '%1' folder selected for the treatment reports").arg(_logPathNames[vLogType])); } /*! @@ -338,8 +346,10 @@ if (logPathName.isEmpty()) logPathName = _logPathNames[eLogDebug]; _logFileName = logPathName + fileName; - FileHandler::write(_logFileName, mContent + "\r\n", true); + bool isWritten = FileHandler::write(_logFileName, mContent + "\r\n", true); + if(!isWritten) emit didLogIOFail(); + // console out the log if enabled. if (_enableConsoleOut) { qDebug().noquote() << mContent; @@ -453,6 +463,12 @@ // disabled coco begin validated: This needs user interaction to export to USB device // has been tested manually LOG_DEBUG(QString("Export %1 ended: %2").arg(_logNames[_exportLogsType]).arg(_exportLogsWatcher.result())); + + //DEBUG: qDebug()<< "_exportLogsWatcher.result()" << _exportLogsWatcher.result(); + if(!_exportLogsWatcher.result()){ + emit didLogIOFail(); + return; + } emit didExportLogs(); } // disabled coco end