Index: sources/storage/Logger.cpp =================================================================== diff -u -r2912750c8e787739f2cb2069fee1b33195a9ef54 -r656094cd72dfcb6cec410b8e36570abf5c9d6975 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 2912750c8e787739f2cb2069fee1b33195a9ef54) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 656094cd72dfcb6cec410b8e36570abf5c9d6975) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file Logger.cpp - * \author (last) Behrouz NematiPour - * \date (last) 25-Jul-2023 + * \author (last) Vy + * \date (last) 10-Aug-2023 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * @@ -147,6 +147,11 @@ connect(&_DeviceController, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); + connect(&_DeviceController, SIGNAL( didSettingsPartitionStateChange(bool, bool)), + this , SLOT( onSettingsPartitionStateChange(bool, bool))); + connect(&_DeviceController, SIGNAL( didSettingsPartitionSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSettingsPartitionSpaceChange(bool, qint64, qint64, quint8))); + connect(&_DeviceController, SIGNAL(didCryptSetupMount(bool)), this , SLOT( onCryptSetupMount(bool))); } @@ -204,11 +209,14 @@ */ void Logger::checkLogPath() { - setLogBasePath(); // try to use /media/sd_card on device - if (! setLogPath()) { // check and create log folders & if unsuccessful then - setLogBasePath(true); // try to use temp folder - setLogPath ( ); // check and create log folders // Note: it may require to check for write access regarding device setup - } + // The POST detects the SD card mount state, but logging needs it before + // POST is complete, need to determine via code whether the SD card is mounted + QStorageInfo baseSDCard; + baseSDCard.setPath(SDCard_Base_Path_Name); + bool isSDMounted = !baseSDCard.isRoot(); // When the SD card is not mounted, the path is set to the mount-point's root, ie: '/' + + setLogBasePath(!isSDMounted); // if the SD is not mounted, use tmp folder; else use /media/sd-card + setLogPath ( ); // check and create log folders // Note: it may require to check for write access regarding device setup if using tmp } /*! @@ -585,7 +593,53 @@ } // disabled coco end + /*! + * \brief Logger::onSettingsPartitionStateChange + * \details handle the state change of the settings partition + * \param vReady - The Settings Partition is Ready + * \param vReadonly - The Settings Partition is readonly + */ +void Logger::onSettingsPartitionStateChange(bool vReady, bool vReadonly) +{ +#if BUILD_FOR_DESKTOP + Q_UNUSED(vReady ) + Q_UNUSED(vReadonly ) + _logStorageReady = true; +#else + // Include settings partition state + _logStorageReady = _logStorageReady && vReady && !vReadonly; +#endif +} + +/*! + * \brief Logger::onSettingsPartitionSpaceChange + * \details Settings Partition storage space parameter change slot. + * This slot when called is calling the function concurrentRemoveLogs, + * if percent of available space vPercent is less than Storage::Available_Space_Percent, + * if the Settings Partition is ready (vReady is true) + * \param vReady - The Settings Partition is Ready + * \param vTotal - Total storage space on the Settings Partition + * \param vAvailable - Available storage space on the Settings Partition + * \param vPercent - Percent of available storage space on the Settings Partition + */ +void Logger::onSettingsPartitionSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + // disabled coco begin validated: This needs user interaction to change the SD card files system. + // has been tested manually + Q_UNUSED(vTotal ) + Q_UNUSED(vAvailable ) + if ( ! vReady ) return; + + // DEBUG: qDebug() << vPercent << Storage::Available_Space_Percent; + if ( Storage::Log_Min_Available_Total_Space_IsLow(vPercent) ) { + concurrentRemoveLogs(); + } +} +// disabled coco end + + +/*! * \brief Logger::enableConsoleOut * \details Enables or Disables the console output and logs the status * \param vEnabled - Enable console output if true