This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch simplify_action_interface in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 964e6f593498f4156950505d9b16693879a22bfc Author: Stephen Webb <[email protected]> AuthorDate: Sat May 16 15:18:37 2026 +1000 Simplify the rolling::Action and rolling::RollingPolicy interfaces in the next ABI version --- src/main/cpp/action.cpp | 41 ++++++++++++++++------ src/main/cpp/filerenameaction.cpp | 25 ++++++++++--- src/main/cpp/fixedwindowrollingpolicy.cpp | 30 +++++++--------- src/main/cpp/gzcompressaction.cpp | 21 +++++++---- src/main/cpp/multiprocessrollingfileappender.cpp | 11 +++--- src/main/cpp/rollingfileappender.cpp | 20 +++++------ src/main/cpp/rollingpolicy.cpp | 21 +++++++++++ src/main/cpp/rollingpolicybase.cpp | 13 +++++-- src/main/cpp/timebasedrollingpolicy.cpp | 18 ++++------ src/main/cpp/zipcompressaction.cpp | 24 ++++++++----- src/main/include/log4cxx/private/action_priv.h | 19 +++++----- src/main/include/log4cxx/rolling/action.h | 38 ++++++++++++++++---- .../include/log4cxx/rolling/filerenameaction.h | 7 ++-- .../log4cxx/rolling/fixedwindowrollingpolicy.h | 14 +++----- .../include/log4cxx/rolling/gzcompressaction.h | 7 ++-- src/main/include/log4cxx/rolling/rollingpolicy.h | 36 ++++++++++++++++--- .../include/log4cxx/rolling/rollingpolicybase.h | 9 +++-- .../log4cxx/rolling/timebasedrollingpolicy.h | 12 +++---- .../include/log4cxx/rolling/zipcompressaction.h | 7 ++-- 19 files changed, 241 insertions(+), 132 deletions(-) diff --git a/src/main/cpp/action.cpp b/src/main/cpp/action.cpp index ccc31d4a..8a8933a0 100644 --- a/src/main/cpp/action.cpp +++ b/src/main/cpp/action.cpp @@ -17,8 +17,8 @@ #include <log4cxx/logstring.h> #include <log4cxx/rolling/action.h> #include <log4cxx/private/action_priv.h> +#include <log4cxx/helpers/loglog.h> #include <mutex> -#include <memory> using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::rolling; @@ -38,26 +38,23 @@ Action::~Action() { } -/** - * {@inheritDoc} - */ -void Action::run(LOG4CXX_NS::helpers::Pool& pool1) +void Action::run() { std::lock_guard<std::mutex> lock(m_priv->mutex); - if (!m_priv->interrupted) + if (!m_priv->closed) { try { - execute(pool1); + execute(); } catch (std::exception& ex) { - reportException(ex); + helpers::LogLog::error(getName() + LOG4CXX_STR(" raised the following exception"), ex); } m_priv->complete = true; - m_priv->interrupted = true; + m_priv->closed = true; } } @@ -67,7 +64,7 @@ void Action::run(LOG4CXX_NS::helpers::Pool& pool1) void Action::close() { std::lock_guard<std::mutex> lock(m_priv->mutex); - m_priv->interrupted = true; + m_priv->closed = true; } /** @@ -79,6 +76,18 @@ bool Action::isComplete() const return m_priv->complete; } +LogString Action::getName() const +{ + return m_priv->actionName; +} + +#if LOG4CXX_ABI_VERSION <= 15 +bool Action::execute() const +{ + helpers::Pool p; + return execute(p); +} + /** * Capture exception. * @@ -87,3 +96,15 @@ bool Action::isComplete() const void Action::reportException(const std::exception& /* ex */) { } + +void Action::run(helpers::Pool&) +{ + run(); +} +#else +bool Action::execute(helpers::Pool&) const +{ + return execute(); +} + +#endif diff --git a/src/main/cpp/filerenameaction.cpp b/src/main/cpp/filerenameaction.cpp index 302e6565..3e407617 100644 --- a/src/main/cpp/filerenameaction.cpp +++ b/src/main/cpp/filerenameaction.cpp @@ -27,10 +27,16 @@ using namespace LOG4CXX_NS::helpers; struct FileRenameAction::FileRenameActionPrivate : public ActionPrivate { - FileRenameActionPrivate( const File& toRename, - const File& renameTo, - bool renameEmptyFile1): - source(toRename), destination(renameTo), renameEmptyFile(renameEmptyFile1) {} + FileRenameActionPrivate + ( const File& toRename + , const File& renameTo + , bool renameEmptyFile1 + ) + : ActionPrivate{ LOG4CXX_STR("Rename") } + , source(toRename) + , destination(renameTo) + , renameEmptyFile(renameEmptyFile1) + {} const File source; const File destination; @@ -46,7 +52,18 @@ FileRenameAction::FileRenameAction(const File& toRename, { } +#if LOG4CXX_ABI_VERSION <= 15 bool FileRenameAction::execute(Pool&) const { + if (!priv->renameEmptyFile && 0 == priv->source.length()) + return false; return priv->source.renameTo(priv->destination); } +#else +bool FileRenameAction::execute()const +{ + if (priv->renameEmptyFile || 0 != priv->source.length()) + return priv->source.renameTo(priv->destination); + return false; +} +#endif diff --git a/src/main/cpp/fixedwindowrollingpolicy.cpp b/src/main/cpp/fixedwindowrollingpolicy.cpp index 4f8a442f..ff0162dd 100644 --- a/src/main/cpp/fixedwindowrollingpolicy.cpp +++ b/src/main/cpp/fixedwindowrollingpolicy.cpp @@ -127,10 +127,7 @@ void FixedWindowRollingPolicy::activateOptions( LOG4CXX_ACTIVATE_OPTIONS_FORMAL_ /** * {@inheritDoc} */ -RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( - const LogString& currentActiveFile, - const bool append, - Pool& pool) +RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS ) { LogString newActiveFile(currentActiveFile); priv->explicitActiveFile = false; @@ -145,7 +142,7 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( { LogString buf; ObjectPtr obj = std::make_shared<Integer>(priv->minIndex); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); newActiveFile = buf; } @@ -157,10 +154,7 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( /** * {@inheritDoc} */ -RolloverDescriptionPtr FixedWindowRollingPolicy::rollover( - const LogString& currentActiveFile, - const bool append, - Pool& pool) +RolloverDescriptionPtr FixedWindowRollingPolicy::rollover( LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS ) { RolloverDescriptionPtr desc; @@ -176,14 +170,14 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::rollover( purgeStart++; } - if (!purge(purgeStart, priv->maxIndex, pool)) + if (!purge(purgeStart, priv->maxIndex)) { return desc; } LogString buf; ObjectPtr obj = std::make_shared<Integer>(purgeStart); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); LogString renameTo(buf); LogString compressedName(renameTo); @@ -254,14 +248,14 @@ int FixedWindowRollingPolicy::getMinIndex() const * index will be deleted if needed. * @return true if purge was successful and rollover should be attempted. */ -bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const +bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex) const { int suffixLength = 0; std::vector<FileRenameActionPtr> renames; LogString buf; ObjectPtr obj = std::make_shared<Integer>(lowIndex); - formatFileName(obj, buf, p); + formatFileName(obj, buf); LogString lowFilename(buf); @@ -322,7 +316,7 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const // add a rename action to the list buf.erase(buf.begin(), buf.end()); obj = std::make_shared<Integer>(i + 1); - formatFileName(obj, buf, p); + formatFileName(obj, buf); LogString highFilename(buf); LogString renameTo(highFilename); @@ -349,17 +343,17 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const iter != renames.rend(); iter++) { - + auto& action = *iter; try { - if (!(*iter)->execute(p)) + if (!action->execute()) { return false; } } - catch (std::exception&) + catch (const std::exception& ex) { - LogLog::warn(LOG4CXX_STR("Exception during purge in RollingFileAppender")); + LogLog::warn(action->getName() + LOG4CXX_STR(" raised the following exception"), ex); return false; } diff --git a/src/main/cpp/gzcompressaction.cpp b/src/main/cpp/gzcompressaction.cpp index 41487b17..83e51025 100644 --- a/src/main/cpp/gzcompressaction.cpp +++ b/src/main/cpp/gzcompressaction.cpp @@ -31,10 +31,16 @@ using namespace LOG4CXX_NS::helpers; struct GZCompressAction::GZCompressActionPrivate : public ActionPrivate { - GZCompressActionPrivate( const File& toRename, - const File& renameTo, - bool deleteSource): - source(toRename), destination(renameTo), deleteSource(deleteSource) {} + GZCompressActionPrivate + ( const File& toRename + , const File& renameTo + , bool deleteSource + ) + : ActionPrivate{ LOG4CXX_STR("gzip") } + , source(toRename) + , destination(renameTo) + , deleteSource(deleteSource) + {} const File source; File destination; @@ -54,11 +60,12 @@ GZCompressAction::GZCompressAction(const File& src, GZCompressAction::~GZCompressAction() {} -bool GZCompressAction::execute(LOG4CXX_NS::helpers::Pool& p) const +bool GZCompressAction::execute( LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS ) const { if (priv->source.exists()) { - apr_pool_t* aprpool = p.getAPRPool(); + helpers::Pool tempPool; + apr_pool_t* aprpool = tempPool.getAPRPool(); apr_procattr_t* attr; apr_status_t stat = apr_procattr_create(&attr, aprpool); @@ -124,7 +131,7 @@ bool GZCompressAction::execute(LOG4CXX_NS::helpers::Pool& p) const int i = 0; args[i++] = "gzip"; args[i++] = "-c"; - args[i++] = Transcoder::encode(priv->source.getPath(), p); + args[i++] = Transcoder::encode(priv->source.getPath(), tempPool); args[i++] = NULL; apr_proc_t pid; diff --git a/src/main/cpp/multiprocessrollingfileappender.cpp b/src/main/cpp/multiprocessrollingfileappender.cpp index b898a0be..2e54e169 100644 --- a/src/main/cpp/multiprocessrollingfileappender.cpp +++ b/src/main/cpp/multiprocessrollingfileappender.cpp @@ -281,14 +281,14 @@ bool MultiprocessRollingFileAppender::synchronizedRollover(const TriggeringPolic reopenFile(fileName); else if (trigger && !trigger->isTriggeringEvent(this, _priv->_event, fileName, _priv->fileLength)) ; - else if (auto rollover1 = _priv->rollingPolicy->rollover(fileName, getAppend(), tempPool)) + else if (auto rollover1 = _priv->rollingPolicy->rollover(fileName, getAppend())) { _priv->close(); if (rollover1->getActiveFileName() == fileName) { bool success = true; // A synchronous action is not required if (auto pAction = rollover1->getSynchronous()) - success = pAction->execute(tempPool); + success = pAction->execute(); bool appendToExisting = true; if (success) @@ -307,7 +307,7 @@ bool MultiprocessRollingFileAppender::synchronizedRollover(const TriggeringPolic { try { - asyncAction->execute(tempPool); + asyncAction->execute(); } catch (std::exception& ex) { @@ -337,10 +337,9 @@ bool MultiprocessRollingFileAppender::synchronizedRollover(const TriggeringPolic , rollover1->getAppend() ); _priv->setWriter(createWriter(os)); - helpers::Pool tempPool; bool success = true; // A synchronous action is not required if (auto pAction = rollover1->getSynchronous()) - success = pAction->execute(tempPool); + success = pAction->execute(); if (success) { @@ -357,7 +356,7 @@ bool MultiprocessRollingFileAppender::synchronizedRollover(const TriggeringPolic { try { - asyncAction->execute(tempPool); + asyncAction->execute(); } catch (std::exception& ex) { diff --git a/src/main/cpp/rollingfileappender.cpp b/src/main/cpp/rollingfileappender.cpp index a607037f..c59dd793 100644 --- a/src/main/cpp/rollingfileappender.cpp +++ b/src/main/cpp/rollingfileappender.cpp @@ -219,12 +219,11 @@ bool RollingFileAppender::RollingFileAppenderPriv::activateOptions() std::lock_guard<std::recursive_mutex> lock(this->mutex); this->triggeringPolicy->activateOptions(); this->rollingPolicy->activateOptions(); - Pool p; try { RolloverDescriptionPtr rollover1 = - this->rollingPolicy->initialize(this->fileName, this->fileAppend, p); + this->rollingPolicy->initialize(this->fileName, this->fileAppend); if (rollover1 != NULL) { @@ -232,7 +231,7 @@ bool RollingFileAppender::RollingFileAppenderPriv::activateOptions() if (syncAction != NULL) { - syncAction->execute(p); + syncAction->execute(); } this->fileName = rollover1->getActiveFileName(); @@ -245,7 +244,7 @@ bool RollingFileAppender::RollingFileAppenderPriv::activateOptions() if (asyncAction != NULL) { - asyncAction->execute(p); + asyncAction->execute(); } } @@ -292,7 +291,7 @@ bool RollingFileAppender::rollover() return rolloverInternal(); } #if LOG4CXX_ABI_VERSION <= 15 -bool RollingFileAppender::rollover(Pool& p) +bool RollingFileAppender::rollover(Pool& ) { return rollover(); } @@ -308,8 +307,7 @@ bool RollingFileAppender::rolloverInternal() { try { - Pool p; - RolloverDescriptionPtr rollover1(_priv->rollingPolicy->rollover(this->getFile(), this->getAppend(), p)); + RolloverDescriptionPtr rollover1(_priv->rollingPolicy->rollover(this->getFile(), this->getAppend())); if (rollover1 != NULL) { @@ -325,7 +323,7 @@ bool RollingFileAppender::rolloverInternal() try { - success = rollover1->getSynchronous()->execute(p); + success = rollover1->getSynchronous()->execute(); } catch (std::exception& ex) { @@ -355,7 +353,7 @@ bool RollingFileAppender::rolloverInternal() { try { - asyncAction->execute(p); + asyncAction->execute(); } catch (std::exception& ex) { @@ -388,7 +386,7 @@ bool RollingFileAppender::rolloverInternal() try { - success = rollover1->getSynchronous()->execute(p); + success = rollover1->getSynchronous()->execute(); } catch (std::exception& ex) { @@ -414,7 +412,7 @@ bool RollingFileAppender::rolloverInternal() if (asyncAction != NULL) { - asyncAction->execute(p); + asyncAction->execute(); } } diff --git a/src/main/cpp/rollingpolicy.cpp b/src/main/cpp/rollingpolicy.cpp index fdc8fe94..4842e1e7 100644 --- a/src/main/cpp/rollingpolicy.cpp +++ b/src/main/cpp/rollingpolicy.cpp @@ -22,3 +22,24 @@ using namespace LOG4CXX_NS::rolling; IMPLEMENT_LOG4CXX_OBJECT(RollingPolicy) +#if LOG4CXX_ABI_VERSION <= 15 +RolloverDescriptionPtr RollingPolicy::initialize(const LogString& currentActiveFile, bool append) +{ + helpers::Pool p; + return initialize(currentActiveFile, append, p); +} +RolloverDescriptionPtr RollingPolicy::rollover(const LogString& currentActiveFile, bool append) +{ + helpers::Pool p; + return rollover(currentActiveFile, append, p); +} +#else +RolloverDescriptionPtr RollingPolicy::initialize(const LogString& currentActiveFile, bool append, helpers::Pool&) +{ + return initialize(currentActiveFile, append); +} +RolloverDescriptionPtr RollingPolicy::rollover(const LogString& currentActiveFile, bool append, helpers::Pool&) +{ + return rollover(currentActiveFile, append); +} +#endif diff --git a/src/main/cpp/rollingpolicybase.cpp b/src/main/cpp/rollingpolicybase.cpp index eefb17cb..61897519 100644 --- a/src/main/cpp/rollingpolicybase.cpp +++ b/src/main/cpp/rollingpolicybase.cpp @@ -116,8 +116,7 @@ void RollingPolicyBase::RollingPolicyBasePrivate::parseFileNamePattern(const pat */ void RollingPolicyBase::formatFileName( const ObjectPtr& obj, - LogString& toAppendTo, - Pool& pool) const + LogString& toAppendTo) const { for (auto item : m_priv->patternConverters) { @@ -126,7 +125,15 @@ void RollingPolicyBase::formatFileName( item->getFormattingInfo().format((int)startField, toAppendTo); } } - +#if LOG4CXX_ABI_VERSION <= 15 +void RollingPolicyBase::formatFileName( + const ObjectPtr& obj, + LogString& toAppendTo, + Pool& pool) const +{ + formatFileName(obj, toAppendTo); +} +#endif PatternConverterPtr RollingPolicyBase::getIntegerPatternConverter() const { diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp index 4ea8b22f..eaef45ca 100644 --- a/src/main/cpp/timebasedrollingpolicy.cpp +++ b/src/main/cpp/timebasedrollingpolicy.cpp @@ -315,7 +315,7 @@ void TimeBasedRollingPolicy::activateOptions( LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PA Pool pool; LogString buf; ObjectPtr obj = std::make_shared<Date>(); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); m_priv->lastFileName = buf; m_priv->suffixLength = 0; @@ -348,10 +348,7 @@ LOG4CXX_NS::pattern::PatternMap TimeBasedRollingPolicy::getFormatSpecifiers() co /** * {@inheritDoc} */ -RolloverDescriptionPtr TimeBasedRollingPolicy::initialize( - const LogString& currentActiveFile, - const bool append, - Pool& pool) +RolloverDescriptionPtr TimeBasedRollingPolicy::initialize( LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS ) { Date now; log4cxx_time_t n = now.getTime(); @@ -361,7 +358,7 @@ RolloverDescriptionPtr TimeBasedRollingPolicy::initialize( LogString buf; ObjectPtr obj = std::make_shared<Date>(currentFile.exists() ? currentFile.lastModified() : n); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); m_priv->lastFileName = buf; ActionPtr noAction; @@ -380,10 +377,7 @@ RolloverDescriptionPtr TimeBasedRollingPolicy::initialize( } } -RolloverDescriptionPtr TimeBasedRollingPolicy::rollover( - const LogString& currentActiveFile, - const bool append, - Pool& pool) +RolloverDescriptionPtr TimeBasedRollingPolicy::rollover( LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS ) { Date now; log4cxx_time_t n = now.getTime(); @@ -391,7 +385,7 @@ RolloverDescriptionPtr TimeBasedRollingPolicy::rollover( LogString buf; ObjectPtr obj = std::make_shared<Date>(n); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); LogString newFileName(buf); @@ -402,7 +396,7 @@ RolloverDescriptionPtr TimeBasedRollingPolicy::rollover( { if (getPatternConverterList().size()) { - (*(getPatternConverterList().begin()))->format(obj, m_priv->_fileNamePattern, pool); + (*(getPatternConverterList().begin()))->format(obj, m_priv->_fileNamePattern); } else { diff --git a/src/main/cpp/zipcompressaction.cpp b/src/main/cpp/zipcompressaction.cpp index 0da65bb6..5ef69a37 100644 --- a/src/main/cpp/zipcompressaction.cpp +++ b/src/main/cpp/zipcompressaction.cpp @@ -31,10 +31,16 @@ using namespace LOG4CXX_NS::helpers; struct ZipCompressAction::ZipCompressActionPrivate : public ActionPrivate { - ZipCompressActionPrivate( const File& toRename, - const File& renameTo, - bool deleteSource): - source(toRename), destination(renameTo), deleteSource(deleteSource) {} + ZipCompressActionPrivate + ( const File& toRename + , const File& renameTo + , bool deleteSource + ) + : ActionPrivate{ LOG4CXX_STR("zip") } + , source(toRename) + , destination(renameTo) + , deleteSource(deleteSource) + {} const File source; const File destination; @@ -52,14 +58,14 @@ ZipCompressAction::ZipCompressAction(const File& src, { } -bool ZipCompressAction::execute(LOG4CXX_NS::helpers::Pool& p) const +bool ZipCompressAction::execute( LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS ) const { if (!priv->source.exists()) { return false; } - - apr_pool_t* aprpool = p.getAPRPool(); + helpers::Pool tempPool; + apr_pool_t* aprpool = tempPool.getAPRPool(); apr_procattr_t* attr; apr_status_t stat = apr_procattr_create(&attr, aprpool); @@ -104,8 +110,8 @@ bool ZipCompressAction::execute(LOG4CXX_NS::helpers::Pool& p) const args[i++] = "zip"; args[i++] = "-q"; - args[i++] = Transcoder::encode(priv->destination.getPath(), p); - args[i++] = Transcoder::encode(priv->source.getPath(), p); + args[i++] = Transcoder::encode(priv->destination.getPath(), tempPool); + args[i++] = Transcoder::encode(priv->source.getPath(), tempPool); args[i++] = NULL; if (priv->destination.exists()) diff --git a/src/main/include/log4cxx/private/action_priv.h b/src/main/include/log4cxx/private/action_priv.h index d2688a78..aa9f2061 100644 --- a/src/main/include/log4cxx/private/action_priv.h +++ b/src/main/include/log4cxx/private/action_priv.h @@ -18,6 +18,7 @@ #define LOG4CXX_ACTION_PRIVATE_H #include <log4cxx/rolling/action.h> +#include <mutex> namespace LOG4CXX_NS { @@ -26,25 +27,25 @@ namespace rolling struct Action::ActionPrivate { - ActionPrivate() : - complete(false), - interrupted(false), - pool() {} + ActionPrivate(const LogString& name = LOG4CXX_STR("An action") ) + : actionName(name) + {} virtual ~ActionPrivate(){} /** - * Is action complete. + * Did the action complete. */ - bool complete; + bool complete{ false }; /** - * Is action interrupted. + * Is the action closed. */ - bool interrupted; + bool closed{ false }; - LOG4CXX_NS::helpers::Pool pool; std::mutex mutex; + + LogString actionName; }; } diff --git a/src/main/include/log4cxx/rolling/action.h b/src/main/include/log4cxx/rolling/action.h index c89077f9..48c9d249 100644 --- a/src/main/include/log4cxx/rolling/action.h +++ b/src/main/include/log4cxx/rolling/action.h @@ -20,8 +20,6 @@ #include <log4cxx/helpers/object.h> #include <log4cxx/helpers/pool.h> -#include <mutex> -#include <memory> namespace LOG4CXX_NS { @@ -51,24 +49,50 @@ class Action : public virtual LOG4CXX_NS::helpers::Object public: /** - * Perform action. + * Perform the action. * * @return true if successful. */ - virtual bool execute(LOG4CXX_NS::helpers::Pool& pool) const = 0; +#if LOG4CXX_ABI_VERSION <= 15 + bool execute() const; + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to execute() without a helpers::Pool parameter. + */ + virtual bool execute(helpers::Pool& pool) const = 0; +#define LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS helpers::Pool& p +#else + virtual bool execute() const = 0; +#define LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + [[deprecated("Use execute() without a Pool parameter instead")]] + bool execute(helpers::Pool& pool) const; +#endif - void run(LOG4CXX_NS::helpers::Pool& pool); + /* Call execute() if not already closed. + */ + void run(); + /* Wait until run() completes. + */ void close(); /** - * Tests if the action is complete. - * @return true if action is complete. + * Is action is complete? */ bool isComplete() const; + /* The action description + */ + LogString getName() const; + +#if LOG4CXX_ABI_VERSION <= 15 void reportException(const std::exception&); + void run(helpers::Pool& pool); +#endif }; diff --git a/src/main/include/log4cxx/rolling/filerenameaction.h b/src/main/include/log4cxx/rolling/filerenameaction.h index e17c8d99..96eda924 100644 --- a/src/main/include/log4cxx/rolling/filerenameaction.h +++ b/src/main/include/log4cxx/rolling/filerenameaction.h @@ -44,12 +44,11 @@ class FileRenameAction : public Action const File& renameTo, bool renameEmptyFile); + using Action::execute; /** - * Perform action. - * - * @return true if successful. + * Perform rename. */ - bool execute(LOG4CXX_NS::helpers::Pool& pool) const override; + bool execute( LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS ) const override; }; LOG4CXX_PTR_DEF(FileRenameAction); diff --git a/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h b/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h index b0beca77..19a38f9a 100644 --- a/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h +++ b/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h @@ -83,7 +83,7 @@ class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase */ enum { MAX_WINDOW_SIZE = 12 }; - bool purge(int purgeStart, int maxIndex, LOG4CXX_NS::helpers::Pool& p) const; + bool purge(int purgeStart, int maxIndex) const; public: @@ -122,21 +122,17 @@ class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase void setMaxIndex(int newVal); void setMinIndex(int newVal); + using RollingPolicy::initialize; /** * {@inheritDoc} */ - RolloverDescriptionPtr initialize( - const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + RolloverDescriptionPtr initialize( LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS ) override; + using RollingPolicy::rollover; /** * {@inheritDoc} */ - RolloverDescriptionPtr rollover( - const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + RolloverDescriptionPtr rollover( LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS ) override; protected: /** diff --git a/src/main/include/log4cxx/rolling/gzcompressaction.h b/src/main/include/log4cxx/rolling/gzcompressaction.h index 92184f5d..a8be0a95 100644 --- a/src/main/include/log4cxx/rolling/gzcompressaction.h +++ b/src/main/include/log4cxx/rolling/gzcompressaction.h @@ -45,12 +45,11 @@ class GZCompressAction : public Action bool deleteSource); ~GZCompressAction(); + using Action::execute; /** - * Perform action. - * - * @return true if successful. + * Compress the file. */ - bool execute(LOG4CXX_NS::helpers::Pool& pool) const override; + bool execute( LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS ) const override; /** * Set to true to throw an IOException on a fork failure. By default, this diff --git a/src/main/include/log4cxx/rolling/rollingpolicy.h b/src/main/include/log4cxx/rolling/rollingpolicy.h index 9d2dcc04..59fd965e 100644 --- a/src/main/include/log4cxx/rolling/rollingpolicy.h +++ b/src/main/include/log4cxx/rolling/rollingpolicy.h @@ -51,15 +51,29 @@ class LOG4CXX_EXPORT RollingPolicy : * * @param currentActiveFile current value of RollingFileAppender.getFile(). * @param append current value of RollingFileAppender.getAppend(). - * @param pool pool for memory allocations during call. * @return Description of the initialization, may be null to indicate * no initialization needed. - * @throws SecurityException if denied access to log files. */ +#if LOG4CXX_ABI_VERSION <= 15 + RolloverDescriptionPtr initialize(const LogString& currentActiveFile, bool append); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to initialize() without a helpers::Pool parameter. + */ virtual RolloverDescriptionPtr initialize( const LogString& currentActiveFile, const bool append, LOG4CXX_NS::helpers::Pool& pool) = 0; +#define LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append, helpers::Pool& p +#else + virtual RolloverDescriptionPtr initialize(const LogString& currentActiveFile, bool append) = 0; +#define LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + [[deprecated("Use initialize() without a Pool parameter instead")]] + RolloverDescriptionPtr initialize(const LogString& currentActiveFile, bool append, helpers::Pool& pool); +#endif /** * Prepare for a rollover. This method is called prior to @@ -69,15 +83,29 @@ class LOG4CXX_EXPORT RollingPolicy : * * @param currentActiveFile file name for current active log file. * @param append current value of the parent FileAppender.getAppend(). - * @param pool pool for memory allocations during call. * @return Description of pending rollover, may be null to indicate no rollover * at this time. - * @throws SecurityException if denied access to log files. */ +#if LOG4CXX_ABI_VERSION <= 15 + RolloverDescriptionPtr rollover(const LogString& currentActiveFile, bool append); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to execute() without a helpers::Pool parameter. + */ virtual RolloverDescriptionPtr rollover( const LogString& currentActiveFile, const bool append, LOG4CXX_NS::helpers::Pool& pool) = 0; +#define LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append, helpers::Pool& p +#else + virtual RolloverDescriptionPtr rollover(const LogString& currentActiveFile, bool append) = 0; +#define LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + [[deprecated("Use rollover() without a Pool parameter instead")]] + RolloverDescriptionPtr rollover(const LogString& currentActiveFile, bool append, helpers::Pool& pool); +#endif }; LOG4CXX_PTR_DEF(RollingPolicy); diff --git a/src/main/include/log4cxx/rolling/rollingpolicybase.h b/src/main/include/log4cxx/rolling/rollingpolicybase.h index f2814e04..616bc04b 100644 --- a/src/main/include/log4cxx/rolling/rollingpolicybase.h +++ b/src/main/include/log4cxx/rolling/rollingpolicybase.h @@ -117,13 +117,16 @@ class LOG4CXX_EXPORT RollingPolicyBase * * @param obj object to be evaluted in formatting, may not be null. * @param buf string buffer to which formatted file name is appended, may not be null. - * @param p memory pool. */ - void formatFileName(const helpers::ObjectPtr& obj, - LogString& buf, helpers::Pool& p) const; + void formatFileName(const helpers::ObjectPtr& obj, LogString& buf) const; LOG4CXX_NS::pattern::PatternConverterPtr getIntegerPatternConverter() const; LOG4CXX_NS::pattern::PatternConverterPtr getDatePatternConverter() const; + +#if LOG4CXX_ABI_VERSION <= 15 + void formatFileName(const helpers::ObjectPtr& obj, + LogString& buf, helpers::Pool& p) const; +#endif }; LOG4CXX_PTR_DEF(RollingPolicyBase); diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h index 5d806f08..3c29f618 100755 --- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h +++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h @@ -172,21 +172,17 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy void setMultiprocess(bool multiprocess); + using RollingPolicy::initialize; /** * {@inheritDoc} */ - RolloverDescriptionPtr initialize( - const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + RolloverDescriptionPtr initialize( LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS ) override; + using RollingPolicy::rollover; /** * {@inheritDoc} */ - RolloverDescriptionPtr rollover( - const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + RolloverDescriptionPtr rollover( LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS ) override; /** * Determines if a rollover may be appropriate at this time. If diff --git a/src/main/include/log4cxx/rolling/zipcompressaction.h b/src/main/include/log4cxx/rolling/zipcompressaction.h index fd3d0a37..dbec553f 100644 --- a/src/main/include/log4cxx/rolling/zipcompressaction.h +++ b/src/main/include/log4cxx/rolling/zipcompressaction.h @@ -44,12 +44,11 @@ class ZipCompressAction : public Action const File& destination, bool deleteSource); + using Action::execute; /** - * Perform action. - * - * @return true if successful. + * Compress the file. */ - bool execute(LOG4CXX_NS::helpers::Pool& pool) const override; + bool execute( LOG4CXX_EXECUTE_ACTION_FORMAL_PARAMETERS ) const override; /** * Set to true to throw an IOException on a fork failure. By default, this
