This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new 20c09dc0 Simplify the OptionHandler::activateOptions() usage in a
future ABI version (#634)
20c09dc0 is described below
commit 20c09dc063113a63e1736cf30a5f5f86d10562f4
Author: Stephen Webb <[email protected]>
AuthorDate: Fri Apr 24 13:56:06 2026 +1000
Simplify the OptionHandler::activateOptions() usage in a future ABI version
(#634)
* Use a different deprecation message in each ABI version
* Users can only change their activateOptions override method when using
the next ABI version
* Ensure overriden activateOptions methods are invoked when using the next
ABI version
---
src/main/cpp/CMakeLists.txt | 2 ++
src/main/cpp/appenderskeleton.cpp | 13 ++++++++++++
.../cpp/{triggeringpolicy.cpp => errorhandler.cpp} | 15 +++++++++-----
src/main/cpp/filter.cpp | 9 +++++++++
src/main/cpp/layout.cpp | 13 ++++++++++++
.../{triggeringpolicy.cpp => optionhandler.cpp} | 15 +++++++++-----
src/main/cpp/rollingpolicybase.cpp | 9 +++++++++
src/main/cpp/timebasedrollingpolicy.cpp | 13 ++++++++++--
src/main/cpp/triggeringpolicy.cpp | 13 ++++++++++++
src/main/include/log4cxx/appenderskeleton.h | 22 ++++++++++++++++++++-
src/main/include/log4cxx/layout.h | 18 +++++++++++++++++
.../include/log4cxx/rolling/rollingpolicybase.h | 9 +++++++++
.../log4cxx/rolling/timebasedrollingpolicy.h | 3 +++
.../include/log4cxx/rolling/triggeringpolicy.h | 9 +++++++++
src/main/include/log4cxx/spi/errorhandler.h | 8 ++++++++
src/main/include/log4cxx/spi/filter.h | 23 +++++++++++++++++++++-
src/main/include/log4cxx/spi/optionhandler.h | 14 ++++++++++++-
17 files changed, 193 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/appenderskeleton.cpp
b/src/main/cpp/appenderskeleton.cpp
index e7deed4f..1297f3a4 100644
--- a/src/main/cpp/appenderskeleton.cpp
+++ b/src/main/cpp/appenderskeleton.cpp
@@ -50,6 +50,19 @@ AppenderSkeleton::AppenderSkeleton(const LayoutPtr& layout)
AppenderSkeleton::~AppenderSkeleton() {}
+void AppenderSkeleton::activateOptions(helpers::Pool& /* pool */)
+{
+}
+
+#if 15 < LOG4CXX_ABI_VERSION
+void AppenderSkeleton::activateOptions()
+{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ helpers::Pool p;
+ activateOptions(p);
+}
+#endif
+
#if LOG4CXX_ABI_VERSION <= 15
void AppenderSkeleton::finalize()
{
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/errorhandler.cpp
similarity index 76%
copy from src/main/cpp/triggeringpolicy.cpp
copy to src/main/cpp/errorhandler.cpp
index 84b54b97..94a0f078 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/errorhandler.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/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&)
+{
+}
-TriggeringPolicy::~TriggeringPolicy()
+void spi::ErrorHandler::activateOptions()
{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ helpers::Pool p;
+ activateOptions(p);
}
+#endif
\ No newline at end of file
diff --git a/src/main/cpp/filter.cpp b/src/main/cpp/filter.cpp
index c0d8fb2b..4507458c 100644
--- a/src/main/cpp/filter.cpp
+++ b/src/main/cpp/filter.cpp
@@ -49,6 +49,15 @@ void Filter::activateOptions(Pool&)
{
}
+#if 15 < LOG4CXX_ABI_VERSION
+void Filter::activateOptions()
+{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ helpers::Pool p;
+ activateOptions(p);
+}
+#endif
+
void Filter::setOption(const LogString&, const LogString&)
{
}
diff --git a/src/main/cpp/layout.cpp b/src/main/cpp/layout.cpp
index d06d0dd7..dedef5d7 100644
--- a/src/main/cpp/layout.cpp
+++ b/src/main/cpp/layout.cpp
@@ -50,3 +50,16 @@ size_t Layout::getFormattedEventCharacterCount() const
format(text, exampleEvent, pool);
return text.size();
}
+
+#if 15 < LOG4CXX_ABI_VERSION
+void Layout::activateOptions(Pool&)
+{
+}
+
+void Layout::activateOptions()
+{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ Pool p;
+ activateOptions(p);
+}
+#endif
\ No newline at end of file
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/optionhandler.cpp
similarity index 76%
copy from src/main/cpp/triggeringpolicy.cpp
copy to src/main/cpp/optionhandler.cpp
index 84b54b97..54be38e9 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>
+#include <log4cxx/helpers/pool.h>
using namespace LOG4CXX_NS;
-using namespace LOG4CXX_NS::rolling;
using namespace LOG4CXX_NS::helpers;
-IMPLEMENT_LOG4CXX_OBJECT(TriggeringPolicy)
+void spi::OptionHandler::activateOptions(Pool&)
+{
+}
-TriggeringPolicy::~TriggeringPolicy()
+void spi::OptionHandler::activateOptions()
{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ helpers::Pool p;
+ activateOptions(p);
}
+
diff --git a/src/main/cpp/rollingpolicybase.cpp
b/src/main/cpp/rollingpolicybase.cpp
index a4560753..8401da21 100644
--- a/src/main/cpp/rollingpolicybase.cpp
+++ b/src/main/cpp/rollingpolicybase.cpp
@@ -47,6 +47,15 @@ RollingPolicyBase::~RollingPolicyBase()
{
}
+#if 15 < LOG4CXX_ABI_VERSION
+void RollingPolicyBase::activateOptions()
+{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ helpers::Pool p;
+ activateOptions(p);
+}
+#endif
+
void RollingPolicyBase::activateOptions(LOG4CXX_NS::helpers::Pool& /* pool */)
{
if (m_priv->fileNamePatternStr.length() > 0)
diff --git a/src/main/cpp/timebasedrollingpolicy.cpp
b/src/main/cpp/timebasedrollingpolicy.cpp
index 7ce806e8..1abeacbe 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,15 @@ TimeBasedRollingPolicy::TimeBasedRollingPolicy() :
TimeBasedRollingPolicy::~TimeBasedRollingPolicy(){}
+#if 15 < LOG4CXX_ABI_VERSION
+void TimeBasedRollingPolicy::activateOptions()
+{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ 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..fb01ee79 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/triggeringpolicy.cpp
@@ -26,3 +26,16 @@ IMPLEMENT_LOG4CXX_OBJECT(TriggeringPolicy)
TriggeringPolicy::~TriggeringPolicy()
{
}
+
+#if 15 < LOG4CXX_ABI_VERSION
+void TriggeringPolicy::activateOptions(Pool&)
+{
+}
+
+void TriggeringPolicy::activateOptions()
+{
+ // Ensure any ABI 15 overriden activateOptions is invoked
+ helpers::Pool p;
+ activateOptions(p);
+}
+#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..e7492f9d 100644
--- a/src/main/include/log4cxx/appenderskeleton.h
+++ b/src/main/include/log4cxx/appenderskeleton.h
@@ -82,12 +82,32 @@ class LOG4CXX_EXPORT AppenderSkeleton :
[[ deprecated( "The derived appender destructor needs to
implement its cleanup" ) ]]
void finalize();
#endif
+#if LOG4CXX_ABI_VERSION <= 15
+ /**
+ \copybrief spi::OptionHandler::activateOptions()
+
+ No action is performed in this implementation.
+
+ @deprecated The \c pool parameter is not required and will be
removed in a future version.
+ */
+ void activateOptions(helpers::Pool& pool) override;
+#else
/**
\copybrief spi::OptionHandler::activateOptions()
No action is performed in this implementation.
+
+ @deprecated This function is deprecated and will be removed in
a future version.
*/
- void activateOptions(helpers::Pool& /* pool */) override {}
+ [[deprecated("Override activateOptions() without parameters
instead")]]
+ void activateOptions(helpers::Pool& ) override;
+ /**
+ \copybrief spi::OptionHandler::activateOptions()
+
+ No action is performed in this implementation.
+ */
+ 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..33cc2ca0 100644
--- a/src/main/include/log4cxx/layout.h
+++ b/src/main/include/log4cxx/layout.h
@@ -76,6 +76,24 @@ 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() override;
+
+ /**
+ \copybrief spi::OptionHandler::activateOptions()
+
+ No action is performed in this implementation.
+ @deprecated This function is deprecated and will be removed in
a future version.
+ */
+ [[deprecated("Override activateOptions() without parameters
instead")]]
+ void activateOptions(helpers::Pool& ) 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..769f0f9c 100644
--- a/src/main/include/log4cxx/spi/filter.h
+++ b/src/main/include/log4cxx/spi/filter.h
@@ -102,12 +102,33 @@ class LOG4CXX_EXPORT Filter : public virtual OptionHandler
};
+#if LOG4CXX_ABI_VERSION <= 15
/**
\copybrief spi::OptionHandler::activateOptions()
No action is performed in this implementation.
+
+ @deprecated The \c pool parameter is not required and will be
removed in a future version.
+ */
+ void activateOptions(helpers::Pool& /* pool */) override;
+#else
+ /**
+ \copybrief spi::OptionHandler::activateOptions()
+
+ No action is performed in this implementation.
+ */
+ void activateOptions() override;
+
+ /**
+ \copybrief spi::OptionHandler::activateOptions()
+
+ No action is performed in this implementation.
+
+ @deprecated This function is deprecated and will be removed in
a future version.
*/
- void activateOptions(helpers::Pool& p) override;
+ [[deprecated("Override activateOptions() without parameters
instead")]]
+ void activateOptions(helpers::Pool& ) 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..1065677d 100644
--- a/src/main/include/log4cxx/spi/optionhandler.h
+++ b/src/main/include/log4cxx/spi/optionhandler.h
@@ -49,8 +49,20 @@ 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
+ void activateOptions();
+ /**
+ @deprecated The \c pool parameter is not required and will be
removed in a future version.
+ */
virtual void activateOptions(helpers::Pool& p) = 0;
-
+#else
+ virtual void activateOptions() = 0;
+ /**
+ @deprecated This function is deprecated and will be removed in
a future version.
+ */
+ [[deprecated("Override activateOptions() without parameters
instead")]]
+ virtual void activateOptions(helpers::Pool& );
+#endif
/**
Set <code>option</code> to <code>value</code>.