You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2023/12/27 05:03:55 UTC
(logging-log4cxx) branch prepare_for_abi_16 created (now 8f7ac4c0)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch prepare_for_abi_16
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at 8f7ac4c0 Use LOG4CXX_ABI_VERSION macro to automate the transition to a new ABI version
This branch includes the following new commits:
new 8f7ac4c0 Use LOG4CXX_ABI_VERSION macro to automate the transition to a new ABI version
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4cxx) 01/01: Use LOG4CXX_ABI_VERSION macro to automate the transition to a new ABI version
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch prepare_for_abi_16
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 8f7ac4c05f9b95f867e0cb5c6e611bf7961aa4e8
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed Dec 27 16:03:34 2023 +1100
Use LOG4CXX_ABI_VERSION macro to automate the transition to a new ABI version
---
src/main/cpp/CMakeLists.txt | 4 ---
src/main/cpp/aprinitializer.cpp | 2 +-
src/main/cpp/asyncappender.cpp | 4 +--
src/main/cpp/class.cpp | 13 ++++-----
src/main/cpp/logmanager.cpp | 4 +++
src/main/include/log4cxx/hierarchy.h | 28 +++++++++++-------
src/main/include/log4cxx/log4cxx.h.in | 1 +
src/main/include/log4cxx/spi/loggerrepository.h | 38 ++++++++++++++++++++++++-
src/site/doxy/Doxyfile.in | 3 +-
9 files changed, 69 insertions(+), 28 deletions(-)
diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt
index 60d6c91f..616de883 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 c58c5661..a468ec1c 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 c8389840..1c79cbe2 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<LogString, DiscardSummary> 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 3de1a79f..2bbcc6b9 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 ae03711a..3fe23556 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<Hierarchy*>(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 e6cb9426..38632304 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 <code>l</code> or
+ Enable logging for logging requests with level <code>newLevel</code> 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 c317f8ef..53252f30 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 d03eb119..e9458520 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 <code>factory</code>.
+
+ @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 8f5b5b4a..242371df 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