Index: sources/storage/Logger.h =================================================================== diff -u -re159592e3a99658e661ab83fffef43322dc075f3 -r903697f659a275a5be31d05c460dae628f532aab --- sources/storage/Logger.h (.../Logger.h) (revision e159592e3a99658e661ab83fffef43322dc075f3) +++ sources/storage/Logger.h (.../Logger.h) (revision 903697f659a275a5be31d05c460dae628f532aab) @@ -28,10 +28,11 @@ #define LOG_EXPORT _Logger.concurrentExportLogs() -#define LOG_DEBUG(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDebug) +#define LOG_DEBUG(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDebug, true ) -#define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent) -#define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum) +#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 ) +#define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum, true ) #define MIXED_EVENT_DATUM @@ -84,17 +85,22 @@ eLogEvent, ///< Massages on the CANBus : Error is an event type eLogDatum, ///< Massages on the CANBus : Broadcast data type + eLogTrtmt, ///< Treatment Log Files + eLogType_Count, }; + Q_ENUM(LogType) private: + 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\r\n"; QDir _dir; QString _logFileNamePrefix; - QHash _logPathNames; + QHash _logPathNames; const QHash _logBasePathNames { { LogType::eLogEvent, "log/" }, { LogType::eLogDatum, "log/" }, { LogType::eLogDebug, "service/" }, + { LogType::eLogTrtmt, Storage::Treatment_Log_Folder }, }; const QHash _logPrefix { // Will be used for the logging in the file @@ -111,6 +117,7 @@ { LogType::eLogDatum, ".dat" }, #endif { LogType::eLogDebug, ".err" }, + { LogType::eLogTrtmt, ".log" }, }; // be careful when defining these percentages @@ -120,17 +127,19 @@ // so it is 70% for Event/Datum + 15% Service + 15% free = 100% total const QHash _logTypeMaxUsageLimit { #ifdef MIXED_EVENT_DATUM - { LogType::eLogEvent, 70 }, // in days - { LogType::eLogDatum, 70 }, // in days + { LogType::eLogEvent, 70 }, // in percent + { LogType::eLogDatum, 70 }, // in percent #else - { LogType::eLogEvent, 35 }, // in days - { LogType::eLogDatum, 35 }, // in days + { LogType::eLogEvent, 35 }, // in percent + { LogType::eLogDatum, 35 }, // in percent #endif - { LogType::eLogDebug, 15 }, // in days + { LogType::eLogDebug, 15 }, // in percent + // Not Sure yet so commented out in the remove. + { LogType::eLogTrtmt, 100}, // in percent // No Remove for now }; - const char *_dateFormat = "yyyy_MM_dd"; - const char *_timeFormat = "HH:mm:ss"; + const char *_dateFormat = "yyyy_MM_dd" ; // date used in the file name + const char *_timeFormat = "HH:mm:ss.zzz"; // timestamp in the file const char *_dateSeparator = "_"; // used in filename const char *_separator = ","; @@ -149,10 +158,14 @@ public: void enableConsoleOut(bool vEnabled); +signals: + void didLogPathSet(Logger::LogType vLogType, const QString &vLogPath); + public slots: bool init(); bool init(QThread &vThread); + private slots: void quit(); @@ -168,6 +181,8 @@ void setLogBasePath (bool vUseApplicationDirPath = false); bool setLogPath (); bool setLogPath (LogType vLogType); +public: + const QString &logPath(Logger::LogType vLogType); // ----- Export structure private : @@ -200,9 +215,9 @@ // ----- logging structure private slots: - void onLog (const QString &vContent, LogType vLogType); + void onLog (const QString &vContent, LogType vLogType, bool vTimestamp); private: - void log (const QString &vContent, LogType vLogType); + void log (const QString &vContent, LogType vLogType, bool vTimestamp); signals: /*! @@ -211,6 +226,6 @@ * \param vContent - content as type of string to be logged * \param vLogType - the type of logging of type Storage::Logger::LogType */ - void didLog (const QString &vContent, LogType vLogType); + void didLog (const QString &vContent, LogType vLogType, bool vTimestamp); }; }