diff --git a/CMakeLists.txt b/CMakeLists.txt index f5e7f4f..61bbbf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -40,7 +41,13 @@ ENDIF(WIN32) SET(library_target CuteLogger) -ADD_LIBRARY(${library_target} SHARED ${sources} ${includes}) +OPTION( CuteLogger_STATIC "Use CuteLogger Static" OFF ) +IF ( CuteLogger_STATIC ) + ADD_LIBRARY(${library_target} STATIC ${sources} ${includes}) +ELSE() + ADD_LIBRARY(${library_target} SHARED ${sources} ${includes}) +ENDIF() + TARGET_LINK_LIBRARIES(${library_target} Qt5::Core) TARGET_INCLUDE_DIRECTORIES(${library_target} PUBLIC include) diff --git a/include/AbstractAppender.h b/include/AbstractAppender.h index e029b04..8ac2a2b 100644 --- a/include/AbstractAppender.h +++ b/include/AbstractAppender.h @@ -40,10 +40,10 @@ class CUTELOGGERSHARED_EXPORT AbstractAppender const char* function, const QString& category, const QString& message) = 0; private: - QMutex m_writeMutex; + QMutex m_writeMutex{}; Logger::LogLevel m_detailsLevel; - mutable QMutex m_detailsLevelMutex; + mutable QMutex m_detailsLevelMutex{}; }; #endif // ABSTRACTAPPENDER_H diff --git a/include/AbstractStringAppender.h b/include/AbstractStringAppender.h index 78df9e6..369f894 100644 --- a/include/AbstractStringAppender.h +++ b/include/AbstractStringAppender.h @@ -39,8 +39,8 @@ class CUTELOGGERSHARED_EXPORT AbstractStringAppender : public AbstractAppender private: static QByteArray qCleanupFuncinfo(const char*); - QString m_format; - mutable QReadWriteLock m_formatLock; + QString m_format{}; + mutable QReadWriteLock m_formatLock{}; }; #endif // ABSTRACTSTRINGAPPENDER_H diff --git a/include/Logger.h b/include/Logger.h index 509bc5f..0069821 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -188,7 +188,7 @@ class CUTELOGGERSHARED_EXPORT CuteMessageLogger int m_line; const char* m_function; const char* m_category; - QString m_message; + QString m_message{}; }; @@ -224,13 +224,13 @@ class CUTELOGGERSHARED_EXPORT LoggerTimingHelper private: Logger* m_logger; - QTime m_time; + QTime m_time{}; Logger::LogLevel m_logLevel; Logger::TimingMode m_timingMode; const char* m_file; int m_line; const char* m_function; - QString m_block; + QString m_block{}; }; diff --git a/include/RollingFileAppender.h b/include/RollingFileAppender.h index a5f6c09..e65d328 100644 --- a/include/RollingFileAppender.h +++ b/include/RollingFileAppender.h @@ -65,13 +65,13 @@ class CUTELOGGERSHARED_EXPORT RollingFileAppender : public FileAppender void removeOldFiles(); void setDatePatternString(const QString& datePatternString); - QString m_datePatternString; + QString m_datePatternString{}; DatePattern m_frequency; - QDateTime m_rollOverTime; - QString m_rollOverSuffix; + QDateTime m_rollOverTime{}; + QString m_rollOverSuffix{}; int m_logFilesLimit; - mutable QMutex m_rollingMutex; + mutable QMutex m_rollingMutex{}; }; #endif // ROLLINGFILEAPPENDER_H diff --git a/src/AbstractStringAppender.cpp b/src/AbstractStringAppender.cpp index ce64aae..b78339a 100644 --- a/src/AbstractStringAppender.cpp +++ b/src/AbstractStringAppender.cpp @@ -198,7 +198,7 @@ QByteArray AbstractStringAppender::qCleanupFuncinfo(const char* name) info.truncate(++pos); if (info.at(pos - 1) == ')') { - if (info.indexOf(operator_call) == pos - (int)strlen(operator_call)) + if (info.indexOf(operator_call) == pos - static_cast(strlen(operator_call))) break; // this function returns a pointer to a function @@ -224,19 +224,19 @@ QByteArray AbstractStringAppender::qCleanupFuncinfo(const char* name) if (pos > -1) { switch (info.at(pos)) { case ')': - if (info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1) + if (info.indexOf(operator_call) == pos - static_cast(strlen(operator_call)) + 1) pos -= 2; break; case '<': - if (info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1) + if (info.indexOf(operator_lessThan) == pos - static_cast(strlen(operator_lessThan)) + 1) --pos; break; case '>': - if (info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1) + if (info.indexOf(operator_greaterThan) == pos - static_cast(strlen(operator_greaterThan)) + 1) --pos; break; case '=': { - int operatorLength = (int)strlen(operator_lessThanEqual); + int operatorLength = static_cast(strlen(operator_lessThanEqual)); if (info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1) pos -= 2; else if (info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1) diff --git a/src/Logger.cpp b/src/Logger.cpp index 16a18db..236fbd4 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -480,14 +480,14 @@ class LoggerPrivate static Logger* globalInstance; static QReadWriteLock globalInstanceLock; - QList appenders; - QMutex loggerMutex; - - QMap categories; - QMultiMap categoryAppenders; - QStringList noAppendersCategories; // appenders{}; + QMutex loggerMutex{}; + + QMap categories{}; + QMultiMap categoryAppenders{}; + QStringList noAppendersCategories{}; //