diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt index 60d6c91fb..616de883e 100644 --- a/src/main/cpp/CMakeLists.txt +++ b/src/main/cpp/CMakeLists.txt @@ -17,7 +17,6 @@ # Options option(LOG4CXX_ABI_CHECK "Check for ABI changes" OFF) -option(LOG4CXX_ABI_15_COMPATIBILITY "Compatibility for legacy 15 ABI, with some global symbols" ON) # Build the log4cxx library add_library(log4cxx) @@ -60,9 +59,6 @@ if(LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER) multiprocessrollingfileappender.cpp ) endif() -if(LOG4CXX_ABI_15_COMPATIBILITY) - target_compile_definitions(log4cxx PRIVATE LOG4CXX_ABI_15_COMPATIBILITY) -endif() if(${ENABLE_FMT_LAYOUT}) list(APPEND extra_classes diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp index c58c5661b..a468ec1cf 100644 --- a/src/main/cpp/aprinitializer.cpp +++ b/src/main/cpp/aprinitializer.cpp @@ -55,7 +55,7 @@ void tlsDestructImpl(void* ptr) } } -#if LOG4CXX_ABI_15_COMPATIBILITY +#if LOG4CXX_ABI_VERSION <= 15 extern "C" void tlsDestruct(void* ptr) { return tlsDestructImpl(ptr); diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp index c83898402..1c79cbe2a 100644 --- a/src/main/cpp/asyncappender.cpp +++ b/src/main/cpp/asyncappender.cpp @@ -36,7 +36,7 @@ using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; using namespace LOG4CXX_NS::spi; -#if !LOG4CXX_ABI_15_COMPATIBILITY +#if 15 < LOG4CXX_ABI_VERSION namespace { #endif @@ -92,7 +92,7 @@ class DiscardSummary typedef std::map DiscardMap; -#if !LOG4CXX_ABI_15_COMPATIBILITY +#if 15 < LOG4CXX_ABI_VERSION } #endif diff --git a/src/main/cpp/class.cpp b/src/main/cpp/class.cpp index 3de1a79f7..2bbcc6b99 100644 --- a/src/main/cpp/class.cpp +++ b/src/main/cpp/class.cpp @@ -76,20 +76,17 @@ using namespace LOG4CXX_NS::rolling; namespace LOG4CXX_NS { +// This function defined in log4cxx.h +#if LOG4CXX_ABI_VERSION <= 15 +LOG4CXX_EXPORT uint32_t libraryVersion() +#else uint32_t libraryVersion() +#endif { - // This function defined in log4cxx.h return LOG4CXX_VERSION; } } -#if LOG4CXX_ABI_15_COMPATIBILITY -LOG4CXX_EXPORT uint32_t libraryVersion() -{ - return LOG4CXX_NS::libraryVersion(); -} -#endif - Class::Class() { } diff --git a/src/main/cpp/logmanager.cpp b/src/main/cpp/logmanager.cpp index ae03711a8..3fe235562 100644 --- a/src/main/cpp/logmanager.cpp +++ b/src/main/cpp/logmanager.cpp @@ -213,8 +213,12 @@ void LogManager::resetConfiguration() bool LogManager::removeLogger(const LogString& name, bool ifNotUsed) { +#if LOG4CXX_ABI_VERSION <= 15 bool result = false; if (auto r = dynamic_cast(getLoggerRepository().get())) result = r->removeLogger(name, ifNotUsed); return result; +#else + return getLoggerRepository()->removeLogger(name, ifNotUsed); +#endif } diff --git a/src/main/include/log4cxx/hierarchy.h b/src/main/include/log4cxx/hierarchy.h index e6cb94268..386323049 100644 --- a/src/main/include/log4cxx/hierarchy.h +++ b/src/main/include/log4cxx/hierarchy.h @@ -76,13 +76,15 @@ class LOG4CXX_EXPORT Hierarchy : public spi::LoggerRepository void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override; - /** - * Remove a previously added HierarchyEventListener. - * - * ABI TODO: Make virtual and add to LoggerRepository. - */ - void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener); - + /** + * Remove a previously added HierarchyEventListener. + * + */ +#if LOG4CXX_ABI_VERSION <= 15 + void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener); +#else + void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override; +#endif /** * Call \c configurator if not yet configured. */ @@ -115,12 +117,12 @@ class LOG4CXX_EXPORT Hierarchy : public spi::LoggerRepository void setThreshold(const LogString& levelStr) override; /** - Enable logging for logging requests with level l or + Enable logging for logging requests with level newLevel or higher. By default all levels are enabled. - @param l The minimum level for which logging requests are sent to - their appenders. */ - void setThreshold(const LevelPtr& l) override; + @param newLevel The minimum level of logging requests that are sent to appenders. + */ + void setThreshold(const LevelPtr& newLevel) override; void fireAddAppenderEvent(const Logger* logger, const Appender* appender) override; @@ -239,7 +241,11 @@ class LOG4CXX_EXPORT Hierarchy : public spi::LoggerRepository @param ifNotUsed If true and use_count() indicates there are other references, do not remove the Logger and return false. @returns true if \c name Logger was removed from the hierarchy. */ +#if LOG4CXX_ABI_VERSION <= 15 bool removeLogger(const LogString& name, bool ifNotUsed = true); +#else + bool removeLogger(const LogString& name, bool ifNotUsed = true) override; +#endif private: diff --git a/src/main/include/log4cxx/log4cxx.h.in b/src/main/include/log4cxx/log4cxx.h.in index c317f8ef2..53252f309 100644 --- a/src/main/include/log4cxx/log4cxx.h.in +++ b/src/main/include/log4cxx/log4cxx.h.in @@ -25,6 +25,7 @@ */ +#define LOG4CXX_ABI_VERSION @log4cxx_ABI_VER@ #define LOG4CXX_VERSION_MAJOR @log4cxx_VERSION_MAJOR@ #define LOG4CXX_VERSION_MINOR @log4cxx_VERSION_MINOR@ #define LOG4CXX_VERSION_PATCH @log4cxx_VERSION_PATCH@ diff --git a/src/main/include/log4cxx/spi/loggerrepository.h b/src/main/include/log4cxx/spi/loggerrepository.h index d03eb1190..e9458520c 100644 --- a/src/main/include/log4cxx/spi/loggerrepository.h +++ b/src/main/include/log4cxx/spi/loggerrepository.h @@ -47,11 +47,19 @@ class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Object /** Add a {@link spi::HierarchyEventListener HierarchyEventListener} - event to the repository. + event to the repository. */ virtual void addHierarchyEventListener(const HierarchyEventListenerPtr& listener) = 0; +#if 15 < LOG4CXX_ABI_VERSION + /** + * Remove a previously added HierarchyEventListener. + * + */ + virtual void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) = 0; +#endif + /** * Call \c configurator if not yet configured. */ @@ -84,11 +92,39 @@ class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Object */ virtual LevelPtr getThreshold() const = 0; + /** + Retrieve the \c name Logger instance + */ virtual LoggerPtr getLogger(const LogString& name) = 0; + /** + Retrieve the \c name Logger instance + + If a logger of that name already exists, then it will be + returned. Otherwise, a new logger will be instantiated by the + provided factory. + + @param name The name of the logger to retrieve. + @param factory The factory that will make the new logger instance. + */ virtual LoggerPtr getLogger(const LogString& name, const spi::LoggerFactoryPtr& factory) = 0; +#if 15 < LOG4CXX_ABI_VERSION + /** + Remove the \c name Logger from the hierarchy. + + Note: The \c name Logger must be retrieved from the hierarchy + \b after any subsequent configuration file change + for the newly loaded settings to be used. + + @param name The logger to remove. + @param ifNotUsed If true and use_count() indicates there are other references, do not remove the Logger and return false. + @returns true if \c name Logger was removed from the hierarchy. + */ + virtual bool removeLogger(const LogString& name, bool ifNotUsed = true) = 0; +#endif + virtual LoggerPtr getRootLogger() const = 0; virtual LoggerPtr exists(const LogString& name) = 0; diff --git a/src/site/doxy/Doxyfile.in b/src/site/doxy/Doxyfile.in index 8f5b5b4a4..242371dfd 100644 --- a/src/site/doxy/Doxyfile.in +++ b/src/site/doxy/Doxyfile.in @@ -2348,7 +2348,8 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = LOG4CXX_NS=log4cxx \ LOG4CXX_WCHAR_T_API \ LOG4CXX_UNICHAR_API \ - LOG4CXX_CFSTRING_API + LOG4CXX_CFSTRING_API \ + LOG4CXX_ABI_VERSION=@log4cxx_ABI_VER@ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The