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 2026/04/22 06:49:42 UTC

(logging-log4cxx) branch simplify_activate_options created (now 48289746)

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

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


      at 48289746 Simplify the OptionHandler::activateOptions() usage in the next ABI version

This branch includes the following new commits:

     new 48289746 Simplify the OptionHandler::activateOptions() usage in the next 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: Simplify the OptionHandler::activateOptions() usage in the next 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 simplify_activate_options
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 48289746fc4385d566fd2b3049a363e46d1c3d20
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed Apr 22 16:49:20 2026 +1000

    Simplify the OptionHandler::activateOptions() usage in the next ABI version
---
 src/main/cpp/CMakeLists.txt                             |  2 ++
 src/main/cpp/{triggeringpolicy.cpp => errorhandler.cpp} | 13 ++++++++-----
 src/main/cpp/filter.cpp                                 | 17 +++++++++++++++++
 src/main/cpp/layout.cpp                                 | 11 +++++++++++
 .../cpp/{triggeringpolicy.cpp => optionhandler.cpp}     | 17 +++++++++++------
 src/main/cpp/rollingpolicybase.cpp                      |  9 +++++++++
 src/main/cpp/timebasedrollingpolicy.cpp                 | 12 ++++++++++--
 src/main/cpp/triggeringpolicy.cpp                       | 11 +++++++++++
 src/main/include/log4cxx/appenderskeleton.h             |  7 +++++++
 src/main/include/log4cxx/layout.h                       | 10 ++++++++++
 src/main/include/log4cxx/rolling/rollingpolicybase.h    |  9 +++++++++
 .../include/log4cxx/rolling/timebasedrollingpolicy.h    |  3 +++
 src/main/include/log4cxx/rolling/triggeringpolicy.h     |  9 +++++++++
 src/main/include/log4cxx/spi/errorhandler.h             |  8 ++++++++
 src/main/include/log4cxx/spi/filter.h                   |  9 ++++++++-
 src/main/include/log4cxx/spi/optionhandler.h            | 10 +++++++++-
 16 files changed, 142 insertions(+), 15 deletions(-)

diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt
index 25edd863..dcbe526d 100644
--- a/src/main/cpp/CMakeLists.txt
+++ b/src/main/cpp/CMakeLists.txt
@@ -112,6 +112,7 @@ target_sources(log4cxx
   defaultconfigurator.cpp
   defaultloggerfactory.cpp
   defaultrepositoryselector.cpp
+  errorhandler.cpp
   exception.cpp
   fallbackerrorhandler.cpp
   file.cpp
@@ -172,6 +173,7 @@ target_sources(log4cxx
   odbcappender.cpp
   onlyonceerrorhandler.cpp
   optionconverter.cpp
+  optionhandler.cpp
   outputdebugstringappender.cpp
   outputstream.cpp
   outputstreamwriter.cpp
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/errorhandler.cpp
similarity index 82%
copy from src/main/cpp/triggeringpolicy.cpp
copy to src/main/cpp/errorhandler.cpp
index 84b54b97..d1a814b8 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/errorhandler.cpp
@@ -14,15 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#include <log4cxx/rolling/triggeringpolicy.h>
+#include <log4cxx/spi/errorhandler.h>
 
 using namespace LOG4CXX_NS;
-using namespace LOG4CXX_NS::rolling;
 using namespace LOG4CXX_NS::helpers;
 
-IMPLEMENT_LOG4CXX_OBJECT(TriggeringPolicy)
+#if 15 < LOG4CXX_ABI_VERSION
+void spi::ErrorHandler::activateOptions(Pool&)
+{
+	activateOptions();
+}
 
-TriggeringPolicy::~TriggeringPolicy()
+void spi::ErrorHandler::activateOptions()
 {
 }
+#endif
\ No newline at end of file
diff --git a/src/main/cpp/filter.cpp b/src/main/cpp/filter.cpp
index c0d8fb2b..bf25827a 100644
--- a/src/main/cpp/filter.cpp
+++ b/src/main/cpp/filter.cpp
@@ -45,10 +45,27 @@ void Filter::setNext(const FilterPtr& newNext)
 	m_priv->next = newNext;
 }
 
+#if LOG4CXX_ABI_VERSION <= 15
 void Filter::activateOptions(Pool&)
 {
 }
 
+void Filter::activateOptions()
+{
+	helpers::Pool p;
+	activateOptions(p);
+}
+#else
+void Filter::activateOptions(Pool&)
+{
+	activateOptions();
+}
+
+void Filter::activateOptions()
+{
+}
+#endif
+
 void Filter::setOption(const LogString&, const LogString&)
 {
 }
diff --git a/src/main/cpp/layout.cpp b/src/main/cpp/layout.cpp
index d06d0dd7..538c7bf4 100644
--- a/src/main/cpp/layout.cpp
+++ b/src/main/cpp/layout.cpp
@@ -50,3 +50,14 @@ size_t Layout::getFormattedEventCharacterCount() const
 	format(text, exampleEvent, pool);
 	return text.size();
 }
+
+#if 15 < LOG4CXX_ABI_VERSION
+void Layout::activateOptions(Pool&)
+{
+	activateOptions();
+}
+
+void Layout::activateOptions()
+{
+}
+#endif
\ No newline at end of file
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/optionhandler.cpp
similarity index 78%
copy from src/main/cpp/triggeringpolicy.cpp
copy to src/main/cpp/optionhandler.cpp
index 84b54b97..316598ee 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/optionhandler.cpp
@@ -14,15 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#include <log4cxx/rolling/triggeringpolicy.h>
+#include <log4cxx/spi/optionhandler.h>
 
 using namespace LOG4CXX_NS;
-using namespace LOG4CXX_NS::rolling;
 using namespace LOG4CXX_NS::helpers;
 
-IMPLEMENT_LOG4CXX_OBJECT(TriggeringPolicy)
-
-TriggeringPolicy::~TriggeringPolicy()
+#if 15 < LOG4CXX_ABI_VERSION
+void spi::OptionHandler::activateOptions(Pool&)
+{
+	activateOptions();
+}
+#else
+void spi::OptionHandler::activateOptions()
 {
+	 helpers::Pool p;
+	 activateOptions(p);
 }
+#endif
diff --git a/src/main/cpp/rollingpolicybase.cpp b/src/main/cpp/rollingpolicybase.cpp
index a4560753..6abf4e8d 100644
--- a/src/main/cpp/rollingpolicybase.cpp
+++ b/src/main/cpp/rollingpolicybase.cpp
@@ -47,7 +47,16 @@ RollingPolicyBase::~RollingPolicyBase()
 {
 }
 
+#if 15 < LOG4CXX_ABI_VERSION
+void RollingPolicyBase::activateOptions(Pool&)
+{
+	activateOptions();
+}
+
+void RollingPolicyBase::activateOptions()
+#else
 void RollingPolicyBase::activateOptions(LOG4CXX_NS::helpers::Pool& /* pool */)
+#endif
 {
 	if (m_priv->fileNamePatternStr.length() > 0)
 	{
diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp
index 7ce806e8..2d6ed057 100644
--- a/src/main/cpp/timebasedrollingpolicy.cpp
+++ b/src/main/cpp/timebasedrollingpolicy.cpp
@@ -54,7 +54,7 @@ struct TimeBasedRollingPolicy::TimeBasedRollingPolicyPrivate{
 		/**
 		 * Time for next determination if time for rollover.
 		 */
-		log4cxx_time_t nextCheck;
+		log4cxx_time_t nextCheck{0};
 
 		/**
 		 * File name at last rollover.
@@ -64,7 +64,7 @@ struct TimeBasedRollingPolicy::TimeBasedRollingPolicyPrivate{
 		/**
 		 * Length of any file type suffix (.gz, .zip).
 		 */
-		int suffixLength;
+		int suffixLength{0};
 
 		/**
 		 * mmap pointer
@@ -267,6 +267,14 @@ TimeBasedRollingPolicy::TimeBasedRollingPolicy() :
 
 TimeBasedRollingPolicy::~TimeBasedRollingPolicy(){}
 
+#if 15 < LOG4CXX_ABI_VERSION
+void TimeBasedRollingPolicy::activateOptions()
+{
+	Pool p;
+	activateOptions(p);
+}
+#endif
+
 void TimeBasedRollingPolicy::activateOptions(LOG4CXX_NS::helpers::Pool& pool)
 {
 	// find out period from the filename pattern
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/triggeringpolicy.cpp
index 84b54b97..4e70eb20 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/triggeringpolicy.cpp
@@ -26,3 +26,14 @@ IMPLEMENT_LOG4CXX_OBJECT(TriggeringPolicy)
 TriggeringPolicy::~TriggeringPolicy()
 {
 }
+
+#if 15 < LOG4CXX_ABI_VERSION
+void TriggeringPolicy::activateOptions(Pool&)
+{
+	activateOptions();
+}
+
+void TriggeringPolicy::activateOptions()
+{
+}
+#endif
\ No newline at end of file
diff --git a/src/main/include/log4cxx/appenderskeleton.h b/src/main/include/log4cxx/appenderskeleton.h
index b63ca46e..6a0c7843 100644
--- a/src/main/include/log4cxx/appenderskeleton.h
+++ b/src/main/include/log4cxx/appenderskeleton.h
@@ -87,7 +87,14 @@ class LOG4CXX_EXPORT AppenderSkeleton :
 
 		No action is performed in this implementation.
 		*/
+#if LOG4CXX_ABI_VERSION <= 15
+		[[deprecated("Override activateOptions() without parameters instead")]]
 		void activateOptions(helpers::Pool& /* pool */) override {}
+		void activateOptions() { helpers::Pool p; activateOptions(p); }
+#else
+		void activateOptions(helpers::Pool& ) override { activateOptions(); }
+		void activateOptions() override {};
+#endif
 
 		/**
 		\copybrief spi::OptionHandler::setOption()
diff --git a/src/main/include/log4cxx/layout.h b/src/main/include/log4cxx/layout.h
index c3931a87..5b99bd26 100644
--- a/src/main/include/log4cxx/layout.h
+++ b/src/main/include/log4cxx/layout.h
@@ -76,6 +76,16 @@ class LOG4CXX_EXPORT Layout :
 		*/
 		virtual bool ignoresThrowable() const = 0;
 
+#if 15 < LOG4CXX_ABI_VERSION
+		/**
+		\copybrief spi::OptionHandler::activateOptions()
+
+		No action is performed in this implementation.
+		*/
+		void activateOptions(helpers::Pool& ) override;
+		void activateOptions() override;
+#endif
+
 	protected:
 		/**
 		 * The expected length of a formatted event excluding the message text
diff --git a/src/main/include/log4cxx/rolling/rollingpolicybase.h b/src/main/include/log4cxx/rolling/rollingpolicybase.h
index e2f85534..f228c59f 100644
--- a/src/main/include/log4cxx/rolling/rollingpolicybase.h
+++ b/src/main/include/log4cxx/rolling/rollingpolicybase.h
@@ -63,6 +63,15 @@ class LOG4CXX_EXPORT RollingPolicyBase :
 
 		\sa RollingPolicy::activateOptions()
 		*/
+
+#if 15 < LOG4CXX_ABI_VERSION
+		/**
+		\copybrief spi::OptionHandler::activateOptions()
+
+		No action is performed in this implementation.
+		*/
+		void activateOptions() override;
+#endif
 		void activateOptions(helpers::Pool& p) override;
 
 		/**
diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
index 8d4628c0..2f9ae007 100755
--- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
@@ -161,6 +161,9 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy : public virtual RollingPolicyBase,
 
 		\sa RollingPolicyBase::activateOptions()
 		*/
+#if 15 < LOG4CXX_ABI_VERSION
+		void activateOptions() override;
+#endif
 		void activateOptions(helpers::Pool& ) override;
 
 		void setMultiprocess(bool multiprocess);
diff --git a/src/main/include/log4cxx/rolling/triggeringpolicy.h b/src/main/include/log4cxx/rolling/triggeringpolicy.h
index ac6b2dba..4721d6af 100644
--- a/src/main/include/log4cxx/rolling/triggeringpolicy.h
+++ b/src/main/include/log4cxx/rolling/triggeringpolicy.h
@@ -70,6 +70,15 @@ class LOG4CXX_EXPORT TriggeringPolicy :
 			const LogString& filename,
 			size_t fileLength) = 0;
 
+#if 15 < LOG4CXX_ABI_VERSION
+		/**
+		\copybrief spi::OptionHandler::activateOptions()
+
+		No action is performed in this implementation.
+		*/
+		void activateOptions(helpers::Pool& ) override;
+		void activateOptions() override;
+#endif
 };
 
 LOG4CXX_PTR_DEF(TriggeringPolicy);
diff --git a/src/main/include/log4cxx/spi/errorhandler.h b/src/main/include/log4cxx/spi/errorhandler.h
index 9eabd6e3..ef0af515 100644
--- a/src/main/include/log4cxx/spi/errorhandler.h
+++ b/src/main/include/log4cxx/spi/errorhandler.h
@@ -128,6 +128,14 @@ class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHandler
 		Has an error been reported?
 		*/
 		virtual bool errorReported() const = 0;
+
+		/**
+		\copybrief spi::OptionHandler::activateOptions()
+
+		No action is performed in this implementation.
+		*/
+		void activateOptions(helpers::Pool& ) override;
+		void activateOptions() override;
 #endif
 };
 
diff --git a/src/main/include/log4cxx/spi/filter.h b/src/main/include/log4cxx/spi/filter.h
index 04163a18..10efc674 100644
--- a/src/main/include/log4cxx/spi/filter.h
+++ b/src/main/include/log4cxx/spi/filter.h
@@ -107,7 +107,14 @@ class LOG4CXX_EXPORT Filter : public virtual OptionHandler
 
 		No action is performed in this implementation.
 		*/
-		void activateOptions(helpers::Pool& p) override;
+#if LOG4CXX_ABI_VERSION <= 15
+		[[deprecated("Override activateOptions() without parameters instead")]]
+		void activateOptions(helpers::Pool& /* pool */) override;
+		void activateOptions();
+#else
+		void activateOptions(helpers::Pool& ) override;
+		void activateOptions() override;
+#endif
 
 		/**
 		\copybrief spi::OptionHandler::setOption()
diff --git a/src/main/include/log4cxx/spi/optionhandler.h b/src/main/include/log4cxx/spi/optionhandler.h
index 7ae414ad..92d3ba3a 100644
--- a/src/main/include/log4cxx/spi/optionhandler.h
+++ b/src/main/include/log4cxx/spi/optionhandler.h
@@ -20,6 +20,9 @@
 
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/object.h>
+#if LOG4CXX_ABI_VERSION <= 15
+#include <log4cxx/helpers/pool.h>
+#endif
 
 namespace LOG4CXX_NS
 {
@@ -49,8 +52,13 @@ class LOG4CXX_EXPORT OptionHandler : public virtual helpers::Object
 		the <code>File</code> and <b>Append</b> options both of
 		which are ambigous until the other is also set.
 		*/
+#if LOG4CXX_ABI_VERSION <= 15
 		virtual void activateOptions(helpers::Pool& p) = 0;
-
+		void activateOptions();
+#else
+		virtual void activateOptions(helpers::Pool& );
+		virtual void activateOptions() = 0;
+#endif
 
 		/**
 		Set <code>option</code> to <code>value</code>.