Index: sources/storage/Logger.h =================================================================== diff -u -r72494685cc15648712935311cb8ff5b208e70cb4 -r630c0a7fe305de7fc1911df4022036c4b10e473e --- sources/storage/Logger.h (.../Logger.h) (revision 72494685cc15648712935311cb8ff5b208e70cb4) +++ sources/storage/Logger.h (.../Logger.h) (revision 630c0a7fe305de7fc1911df4022036c4b10e473e) @@ -18,6 +18,7 @@ #include #include #include +#include // Project #include "main.h" // Doxygen : do not remove @@ -83,6 +84,10 @@ // friends friend class ::tst_logging; + /// TODO + /// Separate the logger from the log remove , export , backup + /// Then remove the eLogTrtmt from here as well. + public : enum LogType { eLogNone = -1, @@ -97,12 +102,36 @@ }; Q_ENUM(LogType) + enum CacheIndex { + eCache1 = 0, + eCache2 = 1, + eCacheIndexCount = 2, + }; + + Q_ENUM(CacheIndex) + +protected: + void timerEvent(QTimerEvent *) override; + private: bool _logStorageReady = true; + static const int _interval = 1000; //ms = 1 second + const char *_headerA = "TimeStamp,ID,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"; const char *_headerD = "TimeStamp,Description"; + + const quint16 _cacheTimeout = 5 ; // seconds timeout until flushes, for slow traffics + quint16 _cacheCounter = _cacheTimeout ; // seconds timeout counter + quint16 _cacheCount = 2000 ; // K message count + QAtomicInt _cacheIndexA = eCache1; + QAtomicInt _cacheIndexD = eCache1; + QStringList _cacheA[eCacheIndexCount]; + QStringList _cacheD[eCacheIndexCount]; + QElapsedTimer _flushElapsedA; + QElapsedTimer _flushElapsedD; + QElapsedTimer _flushElapsedT; QDir _dir; // The HSSerial is going to be the HD Serial always, @@ -153,6 +182,7 @@ { LogType::eLogTrtmt, ".txr" }, // Treatment report }; + // !!!!!!!!!! IMPORTANT !!!!!!!!!! // be careful with these percentages // please refer to the Storage namespace. @@ -169,7 +199,8 @@ const char *_timeFormat = "HH:mm:ss.zzz"; // timestamp in the file const char *_fileSeparator = "_"; // used in filename - const char *_separator = ","; + const char *_sepParam = ","; + const char *_sepLines = "\r\n"; bool _enableConsoleOut = false; @@ -179,6 +210,9 @@ LogType _exportLogsType = eLogNone; QFutureWatcher _exportLogsWatcher; QFutureWatcher _removeLogsWatcher; + QFutureWatcher _flushLogsWatcherA; + QFutureWatcher _flushLogsWatcherD; + QFutureWatcher _flushLogsWatcherT; QThread *_thread = nullptr; bool _init = false; @@ -285,7 +319,6 @@ void onRemoveLogs(); void onCryptSetupMount (bool vPass); void onActionReceive (GuiActionType vAction, const QVariantList &vData); - signals: /*! * \brief didRemoveLogs @@ -295,6 +328,14 @@ * \param vInProgress - true if the log cleanup is in progress, false otherwise. */ void didRemoveLogs(bool vInProgress); + /*! + * \brief didFlushLogs + * \details notification of the floush log + * \param vInProgress + */ + void didFlushLogsA(bool vInProgress); + void didFlushLogsD(bool vInProgress); + void didFlushLogsT(bool vInProgress); // ----- Available space is low private slots: @@ -305,9 +346,20 @@ // ----- logging structure private slots: - void onLog (const QString &vContent, LogType vLogType, bool vTimestamp); + void onLog (const QString &vContent, LogType vLogType, bool vTimestamp); + bool concurrentFlushLogA(); + bool concurrentFlushLogD(); + bool concurrentFlushLogT(); + void onFlushLogsA(); + void onFlushLogsD(); + void onFlushLogsT(); private: - void log (const QString &vContent, LogType vLogType, bool vTimestamp); + bool logOverflow (LogType vLogType); + int logSwitch (int vCacheIndex); + void logTimeout (); + void log (const QString &vContent, LogType vLogType); + int flush ( LogType vLogType); + int flushTimeout(); signals: /*!