You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2022/10/22 13:34:57 UTC

[logging-log4cxx] 01/02: Directly tell the TimeBasedRollingPolicy if it is for multiprocess

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

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

commit ebb9170ab0316f9e167dd3cb4d4cd8d3561407a8
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Wed Oct 19 09:17:14 2022 -0400

    Directly tell the TimeBasedRollingPolicy if it is for multiprocess
---
 src/main/cpp/multiprocessrollingfileappender.cpp          |  6 ++++++
 src/main/cpp/timebasedrollingpolicy.cpp                   | 12 ++----------
 src/main/include/log4cxx/rolling/timebasedrollingpolicy.h |  3 +--
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/main/cpp/multiprocessrollingfileappender.cpp b/src/main/cpp/multiprocessrollingfileappender.cpp
index 5185ab67..6afe6a1f 100644
--- a/src/main/cpp/multiprocessrollingfileappender.cpp
+++ b/src/main/cpp/multiprocessrollingfileappender.cpp
@@ -40,6 +40,7 @@
 #include <log4cxx/rolling/manualtriggeringpolicy.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/private/fileappender_priv.h>
+#include <log4cxx/rolling/timebasedrollingpolicy.h>
 #include <mutex>
 
 using namespace log4cxx;
@@ -560,6 +561,11 @@ TriggeringPolicyPtr MultiprocessRollingFileAppender::getTriggeringPolicy() const
 void MultiprocessRollingFileAppender::setRollingPolicy(const RollingPolicyPtr& policy)
 {
 	_priv->rollingPolicy = policy;
+
+	TimeBasedRollingPolicyPtr timeBased = log4cxx::cast<TimeBasedRollingPolicy>(policy);
+	if( timeBased ){
+		timeBased->setMultiprocess(true);
+	}
 }
 
 /**
diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp
index cf32329d..ec2d6a64 100644
--- a/src/main/cpp/timebasedrollingpolicy.cpp
+++ b/src/main/cpp/timebasedrollingpolicy.cpp
@@ -475,14 +475,6 @@ bool TimeBasedRollingPolicy::isTriggeringEvent(
 	return Date::currentTime() > m_priv->nextCheck;
 }
 
-void TimeBasedRollingPolicy::setOption(const LogString& option,
-									   const LogString& value){
-	if (StringHelper::equalsIgnoreCase(option,
-			LOG4CXX_STR("MULTIPROCESS"),
-			LOG4CXX_STR("multiprocess")))
-	{
-		m_priv->multiprocess = OptionConverter::toBoolean(value, false);
-	}
-
-	RollingPolicyBase::setOption(option, value);
+void TimeBasedRollingPolicy::setMultiprocess(bool multiprocess){
+	m_priv->multiprocess = multiprocess;
 }
diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
index 8aaf60a7..db60fb0d 100755
--- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
@@ -161,8 +161,7 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy : public RollingPolicyBase,
 		virtual ~TimeBasedRollingPolicy();
 		void activateOptions(log4cxx::helpers::Pool& );
 
-		void setOption(const LogString& option,
-					const LogString& value);
+		void setMultiprocess(bool multiprocess);
 
 		/**
 		 * {@inheritDoc}