Index: sources/storage/Logger.h =================================================================== diff -u -r72494685cc15648712935311cb8ff5b208e70cb4 -raccc25a2cefe436401ad04c57713cfa410621317 --- sources/storage/Logger.h (.../Logger.h) (revision 72494685cc15648712935311cb8ff5b208e70cb4) +++ sources/storage/Logger.h (.../Logger.h) (revision accc25a2cefe436401ad04c57713cfa410621317) @@ -83,6 +83,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 +101,33 @@ }; 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 ; // 5 seconds timeout until flushes, for slow traffics + quint16 _cacheCounter = _cachetimeout ; // 5 seconds timeout counter + quint16 _cacheCount = 2000; // 2K message count + CacheIndex _cacheIndex = eCache1; + QStringList _cacheA[eCacheIndexCount]; + QStringList _cacheD[eCacheIndexCount]; + QDir _dir; // The HSSerial is going to be the HD Serial always, @@ -153,6 +178,7 @@ { LogType::eLogTrtmt, ".txr" }, // Treatment report }; + // !!!!!!!!!! IMPORTANT !!!!!!!!!! // be careful with these percentages // please refer to the Storage namespace. @@ -169,7 +195,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 +206,7 @@ LogType _exportLogsType = eLogNone; QFutureWatcher _exportLogsWatcher; QFutureWatcher _removeLogsWatcher; + QFutureWatcher _flushLogsWatcher; QThread *_thread = nullptr; bool _init = false; @@ -285,7 +313,6 @@ void onRemoveLogs(); void onCryptSetupMount (bool vPass); void onActionReceive (GuiActionType vAction, const QVariantList &vData); - signals: /*! * \brief didRemoveLogs @@ -295,6 +322,12 @@ * \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 didFlushLogs(bool vInProgress); // ----- Available space is low private slots: @@ -305,9 +338,15 @@ // ----- logging structure private slots: - void onLog (const QString &vContent, LogType vLogType, bool vTimestamp); + void onLog (const QString &vContent, LogType vLogType, bool vTimestamp); + bool concurrentFlushLog ( LogType vLogType); + void onFlushLogs(); private: - void log (const QString &vContent, LogType vLogType, bool vTimestamp); + bool logOverflow (LogType vLogType); + CacheIndex logSwitch (); + void logTimeout (); + void log (const QString &vContent, LogType vLogType); + int flush ( LogType vLogType); signals: /*!