Index: sources/storage/Logger.h =================================================================== diff -u -r265ce7409a0ea99a4ae059f5ce7978c9cdb10631 -r142f2ddb8ce284c52c0add2acf3ac81f471b78de --- sources/storage/Logger.h (.../Logger.h) (revision 265ce7409a0ea99a4ae059f5ce7978c9cdb10631) +++ sources/storage/Logger.h (.../Logger.h) (revision 142f2ddb8ce284c52c0add2acf3ac81f471b78de) @@ -22,24 +22,22 @@ // Project #include "main.h" // Doxygen : do not remove #include "StorageGlobals.h" +#include "GuiGlobals.h" // Define #define _Logger Storage::Logger::I() -#define LOG_EXPORTLOG _Logger.concurrentExportLogs() -#define LOG_EXPORTERR _Logger.concurrentExportErrs() -#define LOG_EXPORTTRT _Logger.concurrentExportTrts() +#define LOG_EXPORTLOG(vExportName) _Logger.concurrentExportLogs(vExportName) +#define LOG_EXPORTERR(vExportName) _Logger.concurrentExportErrs(vExportName) +#define LOG_EXPORTTRT(vExportName) _Logger.concurrentExportTrts(vExportName) -#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 ADD_APPED_HEADER emit Storage::Logger::I().didLog(_headerA, Storage::Logger::LogType::eLogAppED, false) +#define ADD_DEBUG_HEADER emit Storage::Logger::I().didLog(_headerD, Storage::Logger::LogType::eLogDebug, false) +#define LOG_APPED(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogAppED, true ) #define LOG_DEBUG(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDebug, true ) -#define LOG_EVENT_UI(vCONTENT) emit Storage::Logger::I().didLog("UI," + vCONTENT, Storage::Logger::LogType::eLogEvent, true ) -#define LOG_DATUM_UI(vCONTENT) emit Storage::Logger::I().didLog("UI," + vCONTENT, Storage::Logger::LogType::eLogDatum, true ) +#define LOG_APPED_UI(vCONTENT) emit Storage::Logger::I().didLog("UI," + vCONTENT, Storage::Logger::LogType::eLogAppED, true ) -#define MIXED_EVENT_DATUM - // forward declarations class tst_logging; @@ -48,7 +46,7 @@ /*! * \brief The Logger class * \details Main logger class that has all the required implementation for logging. - * The provided interface is the LOG_DATUM, LOG_EVENT, LOG_DEBUG, LOG_EXPORT defines + * The provided interface is the LOG_EVENT, LOG_DEBUG, LOG_EXPORT defines * and no other methods. * * This object is logging all the registered Denali Messages transactions over the CANBus in CSV format text file. @@ -67,7 +65,7 @@ * PLEASE BE CAREFUL THIS CLASS IS USING QtConcurrent::run FOR THE EXPORT LOG FILES. * AND ONLY PRIVATE VOID LOG (,) IS CALLING IN POOLED THREAD * PLEASE BE VERY CAREFUL. - * ALL THE OTHER CLASSES TO USE THIS CLASS SHOULD ONLY USE LOG_DATUM, LOG_EVENT, LOG_DEBUG + * ALL THE OTHER CLASSES TO USE THIS CLASS SHOULD ONLY USE LOG_EVENT, LOG_DEBUG * TO DO THE LOGGING */ class Logger : public QObject @@ -84,11 +82,8 @@ 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 - eLogDatum, ///< Massages on the CANBus : Broadcast data type - + eLogAppED, ///< Application Events and Data : Massages on the CANBus + eLogDebug, ///< Application Error : Service logs eLogTrtmt, ///< Treatment Log Files eLogType_Count, @@ -99,53 +94,35 @@ 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"; + const char *_headerA = "TimeStamp,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"; QDir _dir; QString _logFileNamePrefix; QHash _logPathNames; const QHash _logBasePathNames { - { LogType::eLogEvent, Storage::Log_Folder_Event }, - { LogType::eLogDatum, Storage::Log_Folder_Data }, + { LogType::eLogAppED, Storage::Log_Folder_Application}, { LogType::eLogDebug, Storage::Log_Folder_Service }, { LogType::eLogTrtmt, Storage::Log_Folder_Treatment }, }; - const QHash _logPrefix { // Will be used for the logging in the file - { LogType::eLogEvent, "E" }, - { LogType::eLogDatum, "D" }, - { 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 + { LogType::eLogAppED, "Log" }, + { LogType::eLogDebug, "Service" }, + { LogType::eLogTrtmt, "Treatment" }, }; const QHash _logFileNameExt { - { LogType::eLogEvent, ".log" }, -#ifdef MIXED_EVENT_DATUM - { LogType::eLogDatum, ".log" }, -#else - { LogType::eLogDatum, ".dat" }, -#endif - { LogType::eLogDebug, ".err" }, - { LogType::eLogTrtmt, ".log" }, + { LogType::eLogAppED, ".log" }, // Application log + { LogType::eLogDebug, ".err" }, // Application error + { LogType::eLogTrtmt, ".txr" }, // Treatment report }; // !!!!!!!!!! IMPORTANT !!!!!!!!!! // be careful with these percentages // please refer to the Storage namespace. const QHash _logTypeMaxUsageLimit { -#ifdef MIXED_EVENT_DATUM - { LogType::eLogEvent, Storage::Log_Max_Allowable_AppED_Space_Percent }, - { LogType::eLogDatum, Storage::Log_Max_Allowable_AppED_Space_Percent }, -#else - { LogType::eLogEvent, Storage::Log_Max_Allowable_Event_Space_Percent }, - { LogType::eLogDatum, Storage::Log_Max_Allowable_Datum_Space_Percent }, -#endif + { LogType::eLogAppED, Storage::Log_Max_Allowable_AppED_Space_Percent }, { LogType::eLogDebug, Storage::Log_Max_Allowable_Debug_Space_Percent }, - // Not Sure yet so commented out in the remove. { LogType::eLogTrtmt, Storage::Log_Max_Allowable_Trtmt_Space_Percent }, }; @@ -198,17 +175,19 @@ // ----- Export structure private : - bool exportLogs(); - bool exportErrs(); - bool exportTrts(); + bool exportList(const Gui::GuiStringIndexMap &vExportList, LogType vLogType); + bool exportLogs(const Gui::GuiStringIndexMap &vExportList); + bool exportErrs(const Gui::GuiStringIndexMap &vExportList); + bool exportTrts(const Gui::GuiStringIndexMap &vExportList); public slots: // this slot is thread safe and can be called from outside by LOG_EXPORT. bool concurrentExportIsOk (); - bool concurrentExportLogs (); - bool concurrentExportErrs (); - bool concurrentExportTrts (); + bool concurrentExportLogs (const Gui::GuiStringIndexMap &vExportList); + bool concurrentExportErrs (const Gui::GuiStringIndexMap &vExportList); + bool concurrentExportTrts (const Gui::GuiStringIndexMap &vExportList); void onExportLogs (); signals: void didExportLogs(); + void didExportStat(quint32 vIndex, const QString &vFileName, quint8 vPercent); // ----- Remove Old Logs structure private: