Index: sources/storage/Logger.h =================================================================== diff -u -r2467780df22b7fdfb309612abe987d116a657327 -r14cd1c61c1b956e7605d63be7450657817d17355 --- sources/storage/Logger.h (.../Logger.h) (revision 2467780df22b7fdfb309612abe987d116a657327) +++ sources/storage/Logger.h (.../Logger.h) (revision 14cd1c61c1b956e7605d63be7450657817d17355) @@ -112,7 +112,7 @@ // The Mode is the device main states comming from HD_OpMode // this is not exactly the HD_OpModes and will be interpreted in desired cycles. // At the moment we decided to have Standby, Treatment, Disinfection, and I am adding Initial as well. - // Initially + // NoRunning // Treatment // Disinfect // DisinfectHeat // later: the UI message needs to get updated and not using SubMode @@ -121,27 +121,31 @@ // DisinfectFlsh // later: the UI message needs to get updated and not using SubMode // "Disinfect" // "Treatment" - const char *_logFileNameMode_init = "NotRunnig"; + const char *_logFileNameMode_init = "NoRunning"; QString _logFileNameMode = "" ; QString _logFileNameDate = "" ; QString _logFileNameTime = "" ; - QHash _logPathNames; - const QHash _logBasePathNames { + typedef QHash TLogData; + typedef QHash TLogMaxUse; + + TLogData _logPathNames; + const TLogData _logBasePathNames { { LogType::eLogAppED, Storage::Log_Folder_Application}, { LogType::eLogDebug, Storage::Log_Folder_Service }, { LogType::eLogCloud, Storage::Log_Folder_CloudSync }, { LogType::eLogTrtmt, Storage::Txr_Folder_Treatment }, }; - const QHash _logNames { // Will be used for the logging in the file + const TLogData _logNames { // Will be used for the logging in the file { LogType::eLogAppED, "Log" }, { LogType::eLogDebug, "Service" }, { LogType::eLogCloud, "Cloud" }, { LogType::eLogTrtmt, "Treatment" }, }; - const QHash _logFileNameExt { + const char * _logFileNamePendingSubExt = "u."; + const TLogData _logFileNameExt { { LogType::eLogAppED, ".log" }, // Application log { LogType::eLogDebug, ".err" }, // Application error { LogType::eLogCloud, ".log" }, // CloudSync debug @@ -151,7 +155,7 @@ // !!!!!!!!!! IMPORTANT !!!!!!!!!! // be careful with these percentages // please refer to the Storage namespace. - const QHash _logTypeMaxUsageLimit { + const TLogMaxUse _logTypeMaxUsageLimit { { LogType::eLogAppED, Storage::Log_Max_Allowable_AppED_Space_Percent }, { LogType::eLogDebug, Storage::Log_Max_Allowable_Debug_Space_Percent }, { LogType::eLogCloud, Storage::Log_Max_Allowable_Cloud_Space_Percent }, @@ -179,6 +183,49 @@ bool _init = false; public: + QString logFileNamePendingSubExt() { + return _logFileNamePendingSubExt; + } + + QString logFileNameExt ( LogType vLogType ) { + return _logFileNameExt[vLogType]; + } + + QString logPathName(LogType vLogType) { + return _logPathNames[vLogType]; + } + + /*! + * \brief logFileNameExt_AD + * \details Finds the type of the log by log file extention. + * \note Since the log file ext of the cloud and UI are the same, this finction will ignore the eLogCloud and will return eLogAppED type instead. + * \param vLogExt - the log file extention. + * \return + */ + LogType logFileNameExt_AD ( const QString &vLogExt ) { + if ( _logFileNameExt.values().contains(vLogExt) ) { + LogType logType = _logFileNameExt.key(vLogExt); + if ( logType == eLogCloud) logType = eLogAppED; + return logType; + } + return eLogNone; + } + + LogType logFileLogType (const QString &vFileName, QString &vFilePath) { + QFileInfo fileInfo(vFileName); + QString ext = fileInfo.suffix(); + LogType logType = logFileNameExt_AD("." + ext); + QString logFilePath; + if ( logType != eLogNone ) { + logFilePath = Log_Folder_Base + _logBasePathNames[logType]; + } + if ( fileInfo.exists(logFilePath + vFileName) ) { + vFilePath = logFilePath; + return logType; + } + return eLogNone; + } +public: void enableConsoleOut(bool vEnabled); void postInit();