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 2024/04/29 08:04:15 UTC

(logging-log4cxx) 01/01: Improve APRInitiializer interface in next ABI version

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch remove_extra_initialize_calls
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 4ae98671efcf48300c4688d6357320cdfbda1fe6
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Mon Apr 29 18:01:00 2024 +1000

    Improve APRInitiializer interface in next ABI version
---
 src/main/cpp/aprinitializer.cpp                   | 6 +++++-
 src/main/cpp/level.cpp                            | 1 -
 src/main/cpp/loggingevent.cpp                     | 4 ++++
 src/main/include/log4cxx/helpers/aprinitializer.h | 4 ++++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp
index f44e9864..889423fd 100644
--- a/src/main/cpp/aprinitializer.cpp
+++ b/src/main/cpp/aprinitializer.cpp
@@ -129,7 +129,11 @@ APRInitializer& APRInitializer::getInstance()
 }
 
 
+#if LOG4CXX_ABI_VERSION <= 15
 log4cxx_time_t APRInitializer::initialize()
+#else
+log4cxx_time_t APRInitializer::getStartTime()
+#endif
 {
 	return getInstance().m_priv->startTime;
 }
@@ -173,7 +177,7 @@ const ObjectPtr& APRInitializer::findOrAddObject(size_t key, std::function<Objec
 	if (m_priv->objects.empty())
 	{
 		// Ensure the internal logger has a longer life than other Log4cxx static data
-		LogLog::debug(LOG4CXX_STR("Log4cxx starting"));
+		LogLog::debug(LOG4CXX_STR("Started"));
 	}
 	auto pItem = m_priv->objects.find(key);
 	if (m_priv->objects.end() == pItem)
diff --git a/src/main/cpp/level.cpp b/src/main/cpp/level.cpp
index 7e2e4dad..50fcfd12 100644
--- a/src/main/cpp/level.cpp
+++ b/src/main/cpp/level.cpp
@@ -85,7 +85,6 @@ Level::Level(int level1,
 	const LogString& name1, int syslogEquivalent1)
 	: level(level1), name(name1), syslogEquivalent(syslogEquivalent1)
 {
-	APRInitializer::initialize();
 }
 
 
diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp
index f6eceddb..18382e89 100644
--- a/src/main/cpp/loggingevent.cpp
+++ b/src/main/cpp/loggingevent.cpp
@@ -173,7 +173,11 @@ IMPLEMENT_LOG4CXX_OBJECT(LoggingEvent)
 //
 log4cxx_time_t LoggingEvent::getStartTime()
 {
+#if LOG4CXX_ABI_VERSION <= 15
 	return LOG4CXX_NS::helpers::APRInitializer::initialize();
+#else
+	return APRInitializer::getStartTime();
+#endif
 }
 
 LoggingEvent::LoggingEvent() :
diff --git a/src/main/include/log4cxx/helpers/aprinitializer.h b/src/main/include/log4cxx/helpers/aprinitializer.h
index ea5945a3..2b608dec 100644
--- a/src/main/include/log4cxx/helpers/aprinitializer.h
+++ b/src/main/include/log4cxx/helpers/aprinitializer.h
@@ -44,7 +44,11 @@ class FileWatchdog;
 class APRInitializer
 {
 	public:
+#if LOG4CXX_ABI_VERSION <= 15
 		static log4cxx_time_t initialize();
+#else
+		static log4cxx_time_t getStartTime();
+#endif
 		static apr_pool_t* getRootPool();
 		static apr_threadkey_t* getTlsKey();
 		static bool isDestructed;