Index: sources/storage/logger.h =================================================================== diff -u -rd04653f0fbf1ed98178b6c7094beb4ec226a777f -r3aab84456cfbdc4c4f495975ba9b8968eb844309 --- sources/storage/logger.h (.../logger.h) (revision d04653f0fbf1ed98178b6c7094beb4ec226a777f) +++ sources/storage/logger.h (.../logger.h) (revision 3aab84456cfbdc4c4f495975ba9b8968eb844309) @@ -29,9 +29,9 @@ #define LOG_EXPORT _Logger.concurrentExport() -#define LOG_BASIC(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogBasic) +#define LOG_DEBUG(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDebug) + #define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent) -#define LOG_ERROR(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogError) #define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum) // forward declarations @@ -42,14 +42,14 @@ /*! * \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_ERROR, LOG_EXPORT defines + * The provided interface is the LOG_DATUM, LOG_EVENT, LOG_DEBUG, LOG_EXPORT defines * and no other methods. * This should have its own thread. * \note * 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_ERROR + * ALL THE OTHER CLASSES TO USE THIS CLASS SHOULD ONLY USE LOG_DATUM, LOG_EVENT, LOG_DEBUG * TO DO THE LOGGING */ class Logger : public QObject @@ -58,44 +58,46 @@ // friends friend class ::tst_logging; + public : enum LogType { - eLogBasic, - eLogEvent, - eLogError, - eLogDatum, + eLogDebug, ///< Application Error : CANBus messages doesn't have error it's Evnet/Data only + eLogEvent, ///< Massages on the CANBus : Error is an event type + eLogDatum, ///< Massages on the CANBus : Broadcast data type + eLogType_Count, }; private: - QDir _dir; - QString _prefix; + QDir _dir; + QString _logFileNamePrefix; QHash _logPathNames; const QHash _logBasePathNames { - { LogType::eLogBasic, "log/" }, { LogType::eLogEvent, "log/" }, { LogType::eLogDatum, "log/" }, - { LogType::eLogError, "service/" }, + { LogType::eLogDebug, "service/" }, }; const QHash _logPrefix { // Will be used for the logging in the file - { LogType::eLogBasic, "" }, // Object itself tells what it is { LogType::eLogEvent, "E" }, { LogType::eLogDatum, "D" }, - { LogType::eLogError, "" }, // it has its own file and all the content is Error + { LogType::eLogDebug, "" }, // it has its own file and all the content is Error }; const QHash _logTypeName { // Will be used for for information - { LogType::eLogBasic, "Basic" }, // Object itself tells what it is { LogType::eLogEvent, "Event" }, { LogType::eLogDatum, "Datum" }, - { LogType::eLogError, "Error" }, // it has its own file and all the content is Error + { LogType::eLogDebug, "Error" }, // it has its own file and all the content is Error }; const QHash _logFileNameExt { - { LogType::eLogBasic, ".log" }, { LogType::eLogEvent, ".log" }, { LogType::eLogDatum, ".log" }, - { LogType::eLogError, ".err" }, - }; + { LogType::eLogDebug, ".err" }, + }; + const QHash _logTypeExpiryDay { + { LogType::eLogEvent, 15 }, + { LogType::eLogDatum, 15 }, + { LogType::eLogDebug, 5 }, + }; const char *_dateFormat = "yyyy_MM_dd"; const char *_timeFormat = "HH:mm:ss"; @@ -108,8 +110,6 @@ QFutureWatcher _exportWatcher; QFutureWatcher _removeOldLogsWatcher; - const quint8 _removeOldLogsDaysOlderThan = 3; - QThread *_thread = nullptr; bool _init = false; @@ -149,17 +149,23 @@ void didExport(); // ----- Remove Old Logs structure +private: + int removeOldLogs(); private slots: bool concurrentRemoveOldLogs(); void onRemoveOldLogs(); signals: void didRemoveOldLogs(); +private slots: + void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + // ----- logging structure private slots: void onLog (const QString &vContent, LogType vLogType); private: void log (const QString &vContent, LogType vLogType); + signals: /*! * \brief didLog