Index: sources/storage/Logger.h =================================================================== diff -u -r54c4136d95375116e6daf23b7d4179159cf13d0c -rfec49d1a8016d25cedff4cf2fefb4c4cd1c7c259 --- sources/storage/Logger.h (.../Logger.h) (revision 54c4136d95375116e6daf23b7d4179159cf13d0c) +++ sources/storage/Logger.h (.../Logger.h) (revision fec49d1a8016d25cedff4cf2fefb4c4cd1c7c259) @@ -26,7 +26,9 @@ // Define #define _Logger Storage::Logger::I() -#define LOG_EXPORT _Logger.concurrentExportLogs() +#define LOG_EXPORTLOG _Logger.concurrentExportLogs() +#define LOG_EXPORTERR _Logger.concurrentExportErrs() +#define LOG_EXPORTTRT _Logger.concurrentExportTrts() #define ADD_EVENT_HEADER emit Storage::Logger::I().didLog(_headerE, Storage::Logger::LogType::eLogEvent, false) #define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent, true ) @@ -38,8 +40,6 @@ #define MIXED_EVENT_DATUM -#undef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG - // forward declarations class tst_logging; @@ -82,6 +82,8 @@ public : enum LogType { + eLogNone = -1, + eLogDebug, ///< Application Error : CANBus messages does not have error it's Event/Data only eLogEvent, ///< Massages on the CANBus : Error is an event type @@ -94,6 +96,9 @@ Q_ENUM(LogType) private: + + bool _logStorageReady = true; + const char *_headerE = "TimeStamp,Type,SubSys,Name,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40"; QDir _dir; QString _logFileNamePrefix; @@ -111,6 +116,12 @@ { LogType::eLogDebug, "" }, // it has its own file and all the content is Error }; + const QHash _logNames { // Will be used for the logging in the file + { LogType::eLogEvent, "Log" }, + { LogType::eLogDatum, "Service" }, + { LogType::eLogDebug, "Treatment" }, // it has its own file and all the content is Error + }; + const QHash _logFileNameExt { { LogType::eLogEvent, ".log" }, #ifdef MIXED_EVENT_DATUM @@ -122,24 +133,20 @@ { LogType::eLogTrtmt, ".log" }, }; - // be careful when defining these percentages - // 1 - Since now both the Log and Datum are in the same place and file they have same percentage. - // if separated then the percentage has to be separated - // 2 - the total in _logTypeExpiryDay is not 100 and it has to be summed up with Storage::Available_Space_Percent. - // so it is 50% for Event/Datum + 15% Service + 35% free = 100% total - // If the available SD-Card size is < Storage::Available_Space_Percent( 15 ) the remove logger will remove any of log types to retain percentage for each (50 for log, 15 for servc) - // The deletion will continue to get 35% free space, as has been calculated above. + // !!!!!!!!!! IMPORTANT !!!!!!!!!! + // be careful with these percentages + // please refer to the Storage namespace. const QHash _logTypeMaxUsageLimit { #ifdef MIXED_EVENT_DATUM - { LogType::eLogEvent, 50 }, // in percent - { LogType::eLogDatum, 50 }, // in percent + { LogType::eLogEvent, Storage::Log_Max_Allowable_AppED_Space_Percent }, + { LogType::eLogDatum, Storage::Log_Max_Allowable_AppED_Space_Percent }, #else - { LogType::eLogEvent, 25 }, // in percent - { LogType::eLogDatum, 25 }, // in percent + { LogType::eLogEvent, Storage::Log_Max_Allowable_Event_Space_Percent }, + { LogType::eLogDatum, Storage::Log_Max_Allowable_Datum_Space_Percent }, #endif - { LogType::eLogDebug, 15 }, // in percent + { LogType::eLogDebug, Storage::Log_Max_Allowable_Debug_Space_Percent }, // Not Sure yet so commented out in the remove. - { LogType::eLogTrtmt, 100}, // in percent // No Remove for now + { LogType::eLogTrtmt, Storage::Log_Max_Allowable_Trtmt_Space_Percent }, }; const char *_dateFormat = "yyyy_MM_dd" ; // date used in the file name @@ -153,6 +160,7 @@ QString _logFileName = ""; QMutex _logRemoveRunning; + LogType _exportLogsType = eLogNone; QFutureWatcher _exportLogsWatcher; QFutureWatcher _removeLogsWatcher; @@ -191,9 +199,14 @@ // ----- Export structure private : bool exportLogs(); + bool exportErrs(); + bool exportTrts(); public slots: // this slot is thread safe and can be called from outside by LOG_EXPORT. - bool concurrentExportLogs(); - void onExportLogs(); + bool concurrentExportIsOk (); + bool concurrentExportLogs (); + bool concurrentExportErrs (); + bool concurrentExportTrts (); + void onExportLogs (); signals: void didExportLogs(); @@ -215,6 +228,7 @@ // ----- Available space is low private slots: + void onSDCardStateChange(bool vReady, bool vReadonly); void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); // ----- logging structure