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 2021/11/06 00:43:12 UTC
[logging-log4cxx] 07/20: Converted more classes to privdata
This is an automated email from the ASF dual-hosted git repository.
rmiddleton pushed a commit to branch LOGCXX-510
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 7abd9c6979205f9282284c30719cc6f28117c1fb
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Thu Nov 4 22:07:42 2021 -0400
Converted more classes to privdata
---
src/main/cpp/action.cpp | 26 ++-------
src/main/cpp/defaultrepositoryselector.cpp | 10 +++-
src/main/cpp/domconfigurator.cpp | 30 ++++++----
src/main/cpp/fallbackerrorhandler.cpp | 22 +++++---
src/main/cpp/fileinputstream.cpp | 27 ++++++---
src/main/cpp/fileoutputstream.cpp | 27 ++++++---
src/main/cpp/filerenameaction.cpp | 18 +++++-
src/main/cpp/formattinginfo.cpp | 55 ++++++++++++++++---
src/main/cpp/gzcompressaction.cpp | 29 ++++++++--
src/main/cpp/htmllayout.cpp | 57 ++++++++++++++++---
src/main/cpp/patternlayout.cpp | 55 ++++++++++++++-----
src/main/cpp/socketoutputstream.cpp | 24 +++++---
src/main/cpp/xmllayout.cpp | 36 +++++++++++-
src/main/cpp/zipcompressaction.cpp | 31 ++++++++---
.../include/log4cxx/helpers/bufferedoutputstream.h | 64 ----------------------
src/main/include/log4cxx/helpers/fileinputstream.h | 6 +-
.../include/log4cxx/helpers/fileoutputstream.h | 4 +-
.../include/log4cxx/helpers/socketoutputstream.h | 4 +-
src/main/include/log4cxx/htmllayout.h | 38 +++----------
src/main/include/log4cxx/pattern/formattinginfo.h | 33 ++---------
src/main/include/log4cxx/patternlayout.h | 23 ++------
.../log4cxx/private/action_priv.h} | 37 +++++++++----
src/main/include/log4cxx/rolling/action.h | 5 +-
.../include/log4cxx/rolling/filerenameaction.h | 4 +-
.../include/log4cxx/rolling/gzcompressaction.h | 5 +-
.../include/log4cxx/rolling/zipcompressaction.h | 4 +-
.../log4cxx/spi/defaultrepositoryselector.h | 5 +-
.../include/log4cxx/varia/fallbackerrorhandler.h | 6 +-
src/main/include/log4cxx/xml/domconfigurator.h | 11 ++--
src/main/include/log4cxx/xml/xmllayout.h | 27 +++------
30 files changed, 409 insertions(+), 314 deletions(-)
diff --git a/src/main/cpp/action.cpp b/src/main/cpp/action.cpp
index 1e6b8b9..43ff238 100644
--- a/src/main/cpp/action.cpp
+++ b/src/main/cpp/action.cpp
@@ -16,6 +16,7 @@
*/
#include <log4cxx/logstring.h>
#include <log4cxx/rolling/action.h>
+#include <log4cxx/private/action_priv.h>
#include <mutex>
using namespace log4cxx;
@@ -24,31 +25,14 @@ using namespace log4cxx::helpers;
IMPLEMENT_LOG4CXX_OBJECT(Action)
-struct Action::priv_data{
- priv_data() :
- complete(false),
- interrupted(false),
- pool(){}
-
- /**
- * Is action complete.
- */
- bool complete;
-
- /**
- * Is action interrupted.
- */
- bool interrupted;
-
- log4cxx::helpers::Pool pool;
- std::mutex mutex;
-};
-
Action::Action() :
- m_priv( std::make_unique<Action::priv_data>() )
+ m_priv( std::make_unique<Action::ActionPrivate>() )
{
}
+Action::Action( std::unique_ptr<ActionPrivate> priv ) :
+ m_priv( std::move(priv) ){}
+
Action::~Action()
{
}
diff --git a/src/main/cpp/defaultrepositoryselector.cpp b/src/main/cpp/defaultrepositoryselector.cpp
index 238e0ac..2dc9a21 100644
--- a/src/main/cpp/defaultrepositoryselector.cpp
+++ b/src/main/cpp/defaultrepositoryselector.cpp
@@ -21,13 +21,19 @@ using namespace log4cxx;
using namespace log4cxx::spi;
using namespace log4cxx::helpers;
+struct DefaultRepositorySelector::DefaultRepositorySelectorPrivate{
+ LoggerRepositoryPtr repository;
+};
DefaultRepositorySelector::DefaultRepositorySelector(const LoggerRepositoryPtr repository1)
- : repository(repository1)
+ : m_priv(std::make_unique<DefaultRepositorySelectorPrivate>())
{
+ m_priv->repository = repository1;
}
+DefaultRepositorySelector::~DefaultRepositorySelector(){}
+
LoggerRepositoryPtr DefaultRepositorySelector::getLoggerRepository()
{
- return repository;
+ return m_priv->repository;
}
diff --git a/src/main/cpp/domconfigurator.cpp b/src/main/cpp/domconfigurator.cpp
index 6d62d09..37979ab 100644
--- a/src/main/cpp/domconfigurator.cpp
+++ b/src/main/cpp/domconfigurator.cpp
@@ -56,6 +56,12 @@ using namespace log4cxx::spi;
using namespace log4cxx::config;
using namespace log4cxx::rolling;
+struct DOMConfigurator::DOMConfiguratorPrivate{
+ helpers::Properties props;
+ spi::LoggerRepositoryPtr repository;
+ spi::LoggerFactoryPtr loggerFactory;
+};
+
#if APR_HAS_THREADS
namespace log4cxx
@@ -117,10 +123,12 @@ IMPLEMENT_LOG4CXX_OBJECT(DOMConfigurator)
#define THREAD_CONFIG_ATTR "threadConfiguration"
DOMConfigurator::DOMConfigurator()
- : props(), repository()
+ : m_priv(std::make_unique<DOMConfiguratorPrivate>())
{
}
+DOMConfigurator::~DOMConfigurator(){}
+
/**
Used internally to parse appenders by IDREF name.
*/
@@ -353,12 +361,12 @@ void DOMConfigurator::parseErrorHandler(Pool& p,
else if (tagName == LOGGER_REF)
{
LogString loggerName(getAttribute(utf8Decoder, currentElement, REF_ATTR));
- LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
+ LoggerPtr logger = m_priv->repository->getLogger(loggerName, m_priv->loggerFactory);
eh->setLogger(logger);
}
else if (tagName == ROOT_REF)
{
- LoggerPtr root = repository->getRootLogger();
+ LoggerPtr root = m_priv->repository->getRootLogger();
eh->setLogger(root);
}
}
@@ -422,7 +430,7 @@ void DOMConfigurator::parseLogger(
LogString loggerName = subst(getAttribute(utf8Decoder, loggerElement, NAME_ATTR));
LogLog::debug(LOG4CXX_STR("Retreiving an instance of Logger."));
- LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
+ LoggerPtr logger = m_priv->repository->getLogger(loggerName, m_priv->loggerFactory);
// Setting up a logger needs to be an atomic operation, in order
// to protect potential log operations while logger
@@ -459,8 +467,8 @@ void DOMConfigurator::parseLoggerFactory(
className,
LoggerFactory::getStaticClass(),
0);
- loggerFactory = log4cxx::cast<LoggerFactory>(obj);
- PropertySetter propSetter(loggerFactory);
+ m_priv->loggerFactory = log4cxx::cast<LoggerFactory>(obj);
+ PropertySetter propSetter(m_priv->loggerFactory);
for (apr_xml_elem* currentElement = factoryElement->first_child;
currentElement;
@@ -486,7 +494,7 @@ void DOMConfigurator::parseRoot(
apr_xml_doc* doc,
AppenderMap& appenders)
{
- LoggerPtr root = repository->getRootLogger();
+ LoggerPtr root = m_priv->repository->getRootLogger();
parseChildrenOfLoggerElement(p, utf8Decoder, rootElement, root, true, doc, appenders);
}
@@ -772,13 +780,13 @@ void DOMConfigurator::setParameter(log4cxx::helpers::Pool& p,
void DOMConfigurator::doConfigure(const File& filename, spi::LoggerRepositoryPtr repository1)
{
repository1->setConfigured(true);
- this->repository = repository1;
+ m_priv->repository = repository1;
LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
msg.append(filename.getPath());
msg.append(LOG4CXX_STR("..."));
LogLog::debug(msg);
- loggerFactory = LoggerFactoryPtr(new DefaultLoggerFactory());
+ m_priv->loggerFactory = LoggerFactoryPtr(new DefaultLoggerFactory());
Pool p;
apr_file_t* fd;
@@ -1026,7 +1034,7 @@ void DOMConfigurator::parse(
if (!thresholdStr.empty() && thresholdStr != NULL_STRING)
{
- repository->setThreshold(thresholdStr);
+ m_priv->repository->setThreshold(thresholdStr);
}
LogString strstrValue = subst(getAttribute(utf8Decoder, element, STRINGSTREAM_ATTR));
@@ -1085,7 +1093,7 @@ LogString DOMConfigurator::subst(const LogString& value)
{
try
{
- return OptionConverter::substVars(value, props);
+ return OptionConverter::substVars(value, m_priv->props);
}
catch (IllegalArgumentException& e)
{
diff --git a/src/main/cpp/fallbackerrorhandler.cpp b/src/main/cpp/fallbackerrorhandler.cpp
index 17068ba..57f55f2 100644
--- a/src/main/cpp/fallbackerrorhandler.cpp
+++ b/src/main/cpp/fallbackerrorhandler.cpp
@@ -30,16 +30,24 @@ using namespace log4cxx::varia;
IMPLEMENT_LOG4CXX_OBJECT(FallbackErrorHandler)
+struct FallbackErrorHandler::FallbackErrorHandlerPrivate {
+ AppenderWeakPtr backup;
+ AppenderWeakPtr primary;
+ std::vector<LoggerPtr> loggers;
+};
+
FallbackErrorHandler::FallbackErrorHandler()
- : backup(), primary(), loggers()
+ : m_priv(std::make_unique<FallbackErrorHandlerPrivate>())
{
}
+FallbackErrorHandler::~FallbackErrorHandler(){}
+
void FallbackErrorHandler::setLogger(const LoggerPtr& logger)
{
LogLog::debug(((LogString) LOG4CXX_STR("FB: Adding logger ["))
+ logger->getName() + LOG4CXX_STR("]."));
- loggers.push_back(logger);
+ m_priv->loggers.push_back(logger);
}
void FallbackErrorHandler::error(const LogString& message,
@@ -57,15 +65,15 @@ void FallbackErrorHandler::error(const LogString& message,
+ message, e);
LogLog::debug(LOG4CXX_STR("FB: INITIATING FALLBACK PROCEDURE."));
- AppenderPtr primaryLocked = primary.lock();
- AppenderPtr backupLocked = backup.lock();
+ AppenderPtr primaryLocked = m_priv->primary.lock();
+ AppenderPtr backupLocked = m_priv->backup.lock();
if ( !primaryLocked || !backupLocked )
{
return;
}
- for (LoggerPtr l : loggers)
+ for (LoggerPtr l : m_priv->loggers)
{
LogLog::debug(((LogString) LOG4CXX_STR("FB: Searching for ["))
+ primaryLocked->getName() + LOG4CXX_STR("] in logger [")
@@ -86,14 +94,14 @@ void FallbackErrorHandler::setAppender(const AppenderPtr& primary1)
{
LogLog::debug(((LogString) LOG4CXX_STR("FB: Setting primary appender to ["))
+ primary1->getName() + LOG4CXX_STR("]."));
- this->primary = primary1;
+ m_priv->primary = primary1;
}
void FallbackErrorHandler::setBackupAppender(const AppenderPtr& backup1)
{
LogLog::debug(((LogString) LOG4CXX_STR("FB: Setting backup appender to ["))
+ backup1->getName() + LOG4CXX_STR("]."));
- this->backup = backup1;
+ m_priv->backup = backup1;
}
void FallbackErrorHandler::activateOptions(Pool&)
diff --git a/src/main/cpp/fileinputstream.cpp b/src/main/cpp/fileinputstream.cpp
index c075193..d9a8917 100644
--- a/src/main/cpp/fileinputstream.cpp
+++ b/src/main/cpp/fileinputstream.cpp
@@ -29,14 +29,23 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
+struct FileInputStream::FileInputStreamPrivate {
+ FileInputStreamPrivate() : fileptr(nullptr){}
+
+ Pool pool;
+ apr_file_t* fileptr;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(FileInputStream)
-FileInputStream::FileInputStream(const LogString& filename) : fileptr(0)
+FileInputStream::FileInputStream(const LogString& filename) :
+ m_priv(std::make_unique<FileInputStreamPrivate>())
{
open(filename);
}
-FileInputStream::FileInputStream(const logchar* filename) : fileptr(0)
+FileInputStream::FileInputStream(const logchar* filename) :
+ m_priv(std::make_unique<FileInputStreamPrivate>())
{
LogString fn(filename);
open(fn);
@@ -47,7 +56,7 @@ void FileInputStream::open(const LogString& filename)
{
apr_fileperms_t perm = APR_OS_DEFAULT;
apr_int32_t flags = APR_READ;
- apr_status_t stat = File().setPath(filename).open(&fileptr, flags, perm, pool);
+ apr_status_t stat = File().setPath(filename).open(&m_priv->fileptr, flags, perm, m_priv->pool);
if (stat != APR_SUCCESS)
{
@@ -60,7 +69,7 @@ FileInputStream::FileInputStream(const File& aFile)
{
apr_fileperms_t perm = APR_OS_DEFAULT;
apr_int32_t flags = APR_READ;
- apr_status_t stat = aFile.open(&fileptr, flags, perm, pool);
+ apr_status_t stat = aFile.open(&m_priv->fileptr, flags, perm, m_priv->pool);
if (stat != APR_SUCCESS)
{
@@ -71,20 +80,20 @@ FileInputStream::FileInputStream(const File& aFile)
FileInputStream::~FileInputStream()
{
- if (fileptr != NULL && !APRInitializer::isDestructed)
+ if (m_priv->fileptr != NULL && !APRInitializer::isDestructed)
{
- apr_file_close(fileptr);
+ apr_file_close(m_priv->fileptr);
}
}
void FileInputStream::close()
{
- apr_status_t stat = apr_file_close(fileptr);
+ apr_status_t stat = apr_file_close(m_priv->fileptr);
if (stat == APR_SUCCESS)
{
- fileptr = NULL;
+ m_priv->fileptr = NULL;
}
else
{
@@ -96,7 +105,7 @@ void FileInputStream::close()
int FileInputStream::read(ByteBuffer& buf)
{
apr_size_t bytesRead = buf.remaining();
- apr_status_t stat = apr_file_read(fileptr, buf.current(), &bytesRead);
+ apr_status_t stat = apr_file_read(m_priv->fileptr, buf.current(), &bytesRead);
int retval = -1;
if (!APR_STATUS_IS_EOF(stat))
diff --git a/src/main/cpp/fileoutputstream.cpp b/src/main/cpp/fileoutputstream.cpp
index 036ede3..526d3d3 100644
--- a/src/main/cpp/fileoutputstream.cpp
+++ b/src/main/cpp/fileoutputstream.cpp
@@ -29,16 +29,25 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
+struct FileOutputStream::FileOutputStreamPrivate{
+ FileOutputStreamPrivate() : fileptr(nullptr){}
+
+ Pool pool;
+ apr_file_t* fileptr;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream)
FileOutputStream::FileOutputStream(const LogString& filename,
- bool append) : pool(), fileptr(open(filename, append, pool))
+ bool append) : m_priv(std::make_unique<FileOutputStreamPrivate>())
{
+ m_priv->fileptr = open(filename, append, m_priv->pool);
}
FileOutputStream::FileOutputStream(const logchar* filename,
- bool append) : pool(), fileptr(open(filename, append, pool))
+ bool append) : m_priv(std::make_unique<FileOutputStreamPrivate>())
{
+ m_priv->fileptr = open(filename, append, m_priv->pool);
}
apr_file_t* FileOutputStream::open(const LogString& filename,
@@ -71,24 +80,24 @@ apr_file_t* FileOutputStream::open(const LogString& filename,
FileOutputStream::~FileOutputStream()
{
- if (fileptr != NULL && !APRInitializer::isDestructed)
+ if (m_priv->fileptr != NULL && !APRInitializer::isDestructed)
{
- apr_file_close(fileptr);
+ apr_file_close(m_priv->fileptr);
}
}
void FileOutputStream::close(Pool& /* p */)
{
- if (fileptr != NULL)
+ if (m_priv->fileptr != NULL)
{
- apr_status_t stat = apr_file_close(fileptr);
+ apr_status_t stat = apr_file_close(m_priv->fileptr);
if (stat != APR_SUCCESS)
{
throw IOException(stat);
}
- fileptr = NULL;
+ m_priv->fileptr = NULL;
}
}
@@ -98,7 +107,7 @@ void FileOutputStream::flush(Pool& /* p */)
void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ )
{
- if (fileptr == NULL)
+ if (m_priv->fileptr == NULL)
{
throw IOException(-1);
}
@@ -110,7 +119,7 @@ void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ )
while (nbytes > 0)
{
apr_status_t stat = apr_file_write(
- fileptr, data + pos, &nbytes);
+ m_priv->fileptr, data + pos, &nbytes);
if (stat != APR_SUCCESS)
{
diff --git a/src/main/cpp/filerenameaction.cpp b/src/main/cpp/filerenameaction.cpp
index 8dc416a..b30bcc5 100644
--- a/src/main/cpp/filerenameaction.cpp
+++ b/src/main/cpp/filerenameaction.cpp
@@ -17,21 +17,35 @@
#include <log4cxx/logstring.h>
#include <log4cxx/rolling/filerenameaction.h>
+#include <log4cxx/private/action_priv.h>
using namespace log4cxx;
using namespace log4cxx::rolling;
using namespace log4cxx::helpers;
+#define priv static_cast<FileRenameActionPrivate*>(m_priv.get())
+
+struct FileRenameAction::FileRenameActionPrivate : public ActionPrivate{
+ FileRenameActionPrivate( const File& toRename,
+ const File& renameTo,
+ bool renameEmptyFile1):
+ source(toRename), destination(renameTo), renameEmptyFile(renameEmptyFile1){}
+
+ const File source;
+ const File destination;
+ bool renameEmptyFile;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(FileRenameAction)
FileRenameAction::FileRenameAction(const File& toRename,
const File& renameTo,
bool renameEmptyFile1)
- : source(toRename), destination(renameTo), renameEmptyFile(renameEmptyFile1)
+ : Action( std::make_unique<FileRenameActionPrivate>(toRename, renameTo, renameEmptyFile1) )
{
}
bool FileRenameAction::execute(log4cxx::helpers::Pool& pool1) const
{
- return source.renameTo(destination, pool1);
+ return priv->source.renameTo(priv->destination, pool1);
}
diff --git a/src/main/cpp/formattinginfo.cpp b/src/main/cpp/formattinginfo.cpp
index c20347b..ce15f5a 100644
--- a/src/main/cpp/formattinginfo.cpp
+++ b/src/main/cpp/formattinginfo.cpp
@@ -22,6 +22,28 @@
using namespace log4cxx;
using namespace log4cxx::pattern;
+struct FormattingInfo::FormattingInfoPrivate{
+ FormattingInfoPrivate(const bool leftAlign1, const int minLength1, const int maxLength1):
+ minLength(minLength1),
+ maxLength(maxLength1),
+ leftAlign(leftAlign1){}
+
+ /**
+ * Minimum length.
+ */
+ const int minLength;
+
+ /**
+ * Maximum length.
+ */
+ const int maxLength;
+
+ /**
+ * Alignment.
+ */
+ const bool leftAlign;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(FormattingInfo)
/**
@@ -32,12 +54,12 @@ IMPLEMENT_LOG4CXX_OBJECT(FormattingInfo)
*/
FormattingInfo::FormattingInfo(
const bool leftAlign1, const int minLength1, const int maxLength1) :
- minLength(minLength1),
- maxLength(maxLength1),
- leftAlign(leftAlign1)
+ m_priv(std::make_unique<FormattingInfoPrivate>(leftAlign1, minLength1, maxLength1))
{
}
+FormattingInfo::~FormattingInfo(){}
+
/**
* Gets default instance.
* @return default instance.
@@ -58,20 +80,35 @@ void FormattingInfo::format(const int fieldStart, LogString& buffer) const
{
int rawLength = int(buffer.length() - fieldStart);
- if (rawLength > maxLength)
+ if (rawLength > m_priv->maxLength)
{
buffer.erase(buffer.begin() + fieldStart,
- buffer.begin() + fieldStart + (rawLength - maxLength));
+ buffer.begin() + fieldStart + (rawLength - m_priv->maxLength));
}
- else if (rawLength < minLength)
+ else if (rawLength < m_priv->minLength)
{
- if (leftAlign)
+ if (m_priv->leftAlign)
{
- buffer.append(minLength - rawLength, (logchar) 0x20 /* ' ' */);
+ buffer.append(m_priv->minLength - rawLength, (logchar) 0x20 /* ' ' */);
}
else
{
- buffer.insert(fieldStart, minLength - rawLength, 0x20 /* ' ' */);
+ buffer.insert(fieldStart, m_priv->minLength - rawLength, 0x20 /* ' ' */);
}
}
}
+
+bool FormattingInfo::isLeftAligned() const
+{
+ return m_priv->leftAlign;
+}
+
+int FormattingInfo::getMinLength() const
+{
+ return m_priv->minLength;
+}
+
+int FormattingInfo::getMaxLength() const
+{
+ return m_priv->maxLength;
+}
diff --git a/src/main/cpp/gzcompressaction.cpp b/src/main/cpp/gzcompressaction.cpp
index b6735a9..d7af63f 100644
--- a/src/main/cpp/gzcompressaction.cpp
+++ b/src/main/cpp/gzcompressaction.cpp
@@ -20,23 +20,40 @@
#include <apr_strings.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/transcoder.h>
+#include <log4cxx/private/action_priv.h>
using namespace log4cxx;
using namespace log4cxx::rolling;
using namespace log4cxx::helpers;
+#define priv static_cast<GZCompressActionPrivate*>(m_priv.get())
+
+struct GZCompressAction::GZCompressActionPrivate : public ActionPrivate{
+ GZCompressActionPrivate( const File& toRename,
+ const File& renameTo,
+ bool deleteSource):
+ source(toRename), destination(renameTo), deleteSource(deleteSource){}
+
+ const File source;
+ const File destination;
+ bool deleteSource;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(GZCompressAction)
GZCompressAction::GZCompressAction(const File& src,
const File& dest,
bool del)
- : source(src), destination(dest), deleteSource(del)
+ : Action(std::make_unique<GZCompressActionPrivate>(
+ src, dest, del))
{
}
+GZCompressAction::~GZCompressAction(){}
+
bool GZCompressAction::execute(log4cxx::helpers::Pool& p) const
{
- if (source.exists(p))
+ if (priv->source.exists(p))
{
apr_pool_t* aprpool = p.getAPRPool();
apr_procattr_t* attr;
@@ -67,7 +84,7 @@ bool GZCompressAction::execute(log4cxx::helpers::Pool& p) const
apr_file_t* child_out;
apr_int32_t flags = APR_FOPEN_READ | APR_FOPEN_WRITE |
APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE;
- stat = destination.open(&child_out, flags, APR_OS_DEFAULT, p);
+ stat = priv->destination.open(&child_out, flags, APR_OS_DEFAULT, p);
if (stat != APR_SUCCESS)
{
@@ -102,7 +119,7 @@ bool GZCompressAction::execute(log4cxx::helpers::Pool& p) const
int i = 0;
args[i++] = "gzip";
args[i++] = "-c";
- args[i++] = Transcoder::encode(source.getPath(), p);
+ args[i++] = Transcoder::encode(priv->source.getPath(), p);
args[i++] = NULL;
@@ -122,9 +139,9 @@ bool GZCompressAction::execute(log4cxx::helpers::Pool& p) const
throw IOException(stat);
}
- if (deleteSource)
+ if (priv->deleteSource)
{
- source.deleteFile(p);
+ priv->source.deleteFile(p);
}
return true;
diff --git a/src/main/cpp/htmllayout.cpp b/src/main/cpp/htmllayout.cpp
index f63e78e..32e8596 100644
--- a/src/main/cpp/htmllayout.cpp
+++ b/src/main/cpp/htmllayout.cpp
@@ -33,14 +33,25 @@ using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace log4cxx::spi;
+struct HTMLLayout::HTMLLayoutPrivate {
+ HTMLLayoutPrivate() : locationInfo(false), title(LOG4CXX_STR("Log4cxx Log Messages")),
+ dateFormat(){}
+
+ // Print no location info by default
+ bool locationInfo; //= false
+
+ LogString title;
+
+ helpers::ISO8601DateFormat dateFormat;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(HTMLLayout)
HTMLLayout::HTMLLayout()
- : locationInfo(false), title(LOG4CXX_STR("Log4cxx Log Messages")),
- dateFormat()
+ : m_priv(std::make_unique<HTMLLayoutPrivate>())
{
- dateFormat.setTimeZone(TimeZone::getGMT());
+ m_priv->dateFormat.setTimeZone(TimeZone::getGMT());
}
@@ -69,7 +80,7 @@ void HTMLLayout::format(LogString& output,
output.append(LOG4CXX_EOL);
output.append(LOG4CXX_STR("<td>"));
- dateFormat.format(output, event->getTimeStamp(), p);
+ m_priv->dateFormat.format(output, event->getTimeStamp(), p);
output.append(LOG4CXX_STR("</td>"));
@@ -112,7 +123,7 @@ void HTMLLayout::format(LogString& output,
output.append(LOG4CXX_STR("</td>"));
output.append(LOG4CXX_EOL);
- if (locationInfo)
+ if (m_priv->locationInfo)
{
output.append(LOG4CXX_STR("<td>"));
const LocationInfo& locInfo = event->getLocationInformation();
@@ -162,7 +173,7 @@ void HTMLLayout::appendHeader(LogString& output, Pool& p)
output.append(LOG4CXX_STR("<head>"));
output.append(LOG4CXX_EOL);
output.append(LOG4CXX_STR("<title>"));
- output.append(title);
+ output.append(m_priv->title);
output.append(LOG4CXX_STR("</title>"));
output.append(LOG4CXX_EOL);
output.append(LOG4CXX_STR("<style type=\"text/css\">"));
@@ -185,7 +196,7 @@ void HTMLLayout::appendHeader(LogString& output, Pool& p)
output.append(LOG4CXX_EOL);
output.append(LOG4CXX_STR("Log session start time "));
- dateFormat.format(output, apr_time_now(), p);
+ m_priv->dateFormat.format(output, apr_time_now(), p);
output.append(LOG4CXX_STR("<br>"));
output.append(LOG4CXX_EOL);
@@ -204,7 +215,7 @@ void HTMLLayout::appendHeader(LogString& output, Pool& p)
output.append(LOG4CXX_STR("<th>Logger</th>"));
output.append(LOG4CXX_EOL);
- if (locationInfo)
+ if (m_priv->locationInfo)
{
output.append(LOG4CXX_STR("<th>File:Line</th>"));
output.append(LOG4CXX_EOL);
@@ -224,3 +235,33 @@ void HTMLLayout::appendFooter(LogString& output, Pool& /* pool */ )
output.append(LOG4CXX_EOL);
output.append(LOG4CXX_STR("</body></html>"));
}
+
+void HTMLLayout::setLocationInfo(bool locationInfoFlag)
+{
+ m_priv->locationInfo = locationInfoFlag;
+}
+
+bool HTMLLayout::getLocationInfo() const
+{
+ return m_priv->locationInfo;
+}
+
+void HTMLLayout::setTitle(const LogString& title1)
+{
+ m_priv->title.assign(title1);
+}
+
+const LogString& HTMLLayout::getTitle() const
+{
+ return m_priv->title;
+}
+
+LogString HTMLLayout::getContentType() const
+{
+ return LOG4CXX_STR("text/html");
+}
+
+bool HTMLLayout::ignoresThrowable() const
+{
+ return false;
+}
diff --git a/src/main/cpp/patternlayout.cpp b/src/main/cpp/patternlayout.cpp
index 0f9712b..d5e3db9 100644
--- a/src/main/cpp/patternlayout.cpp
+++ b/src/main/cpp/patternlayout.cpp
@@ -53,26 +53,50 @@ using namespace log4cxx::helpers;
using namespace log4cxx::spi;
using namespace log4cxx::pattern;
+struct PatternLayout::PatternLayoutPrivate{
+ PatternLayoutPrivate(){}
+ PatternLayoutPrivate(const LogString& pattern) :
+ conversionPattern(pattern){}
+
+ /**
+ * Conversion pattern.
+ */
+ LogString conversionPattern;
+
+ /**
+ * Pattern converters.
+ */
+ LoggingEventPatternConverterList patternConverters;
+
+ /**
+ * Field widths and alignment corresponding to pattern converters.
+ */
+ FormattingInfoList patternFields;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(PatternLayout)
-PatternLayout::PatternLayout()
+PatternLayout::PatternLayout() :
+ m_priv(std::make_unique<PatternLayoutPrivate>())
{
}
/**
Constructs a PatternLayout using the supplied conversion pattern.
*/
-PatternLayout::PatternLayout(const LogString& pattern)
- : conversionPattern(pattern)
+PatternLayout::PatternLayout(const LogString& pattern) :
+ m_priv(std::make_unique<PatternLayoutPrivate>(pattern))
{
Pool pool;
activateOptions(pool);
}
+PatternLayout::~PatternLayout(){}
+
void PatternLayout::setConversionPattern(const LogString& pattern)
{
- conversionPattern = pattern;
+ m_priv->conversionPattern = pattern;
Pool pool;
activateOptions(pool);
}
@@ -82,11 +106,11 @@ void PatternLayout::format(LogString& output,
Pool& pool) const
{
std::vector<FormattingInfoPtr>::const_iterator formatterIter =
- patternFields.begin();
+ m_priv->patternFields.begin();
for (std::vector<LoggingEventPatternConverterPtr>::const_iterator
- converterIter = patternConverters.begin();
- converterIter != patternConverters.end();
+ converterIter = m_priv->patternConverters.begin();
+ converterIter != m_priv->patternConverters.end();
converterIter++, formatterIter++)
{
int startField = (int)output.length();
@@ -102,25 +126,25 @@ void PatternLayout::setOption(const LogString& option, const LogString& value)
LOG4CXX_STR("CONVERSIONPATTERN"),
LOG4CXX_STR("conversionpattern")))
{
- conversionPattern = OptionConverter::convertSpecialChars(value);
+ m_priv->conversionPattern = OptionConverter::convertSpecialChars(value);
}
}
void PatternLayout::activateOptions(Pool&)
{
- LogString pat(conversionPattern);
+ LogString pat(m_priv->conversionPattern);
if (pat.empty())
{
pat = LOG4CXX_STR("%m%n");
}
- patternConverters.erase(patternConverters.begin(), patternConverters.end());
- patternFields.erase(patternFields.begin(), patternFields.end());
+ m_priv->patternConverters.erase(m_priv->patternConverters.begin(), m_priv->patternConverters.end());
+ m_priv->patternFields.erase(m_priv->patternFields.begin(), m_priv->patternFields.end());
std::vector<PatternConverterPtr> converters;
PatternParser::parse(pat,
converters,
- patternFields,
+ m_priv->patternFields,
getFormatSpecifiers());
//
@@ -136,7 +160,7 @@ void PatternLayout::activateOptions(Pool&)
if (eventConverter != NULL)
{
- patternConverters.push_back(eventConverter);
+ m_priv->patternConverters.push_back(eventConverter);
}
}
}
@@ -192,6 +216,11 @@ log4cxx::pattern::PatternMap PatternLayout::getFormatSpecifiers()
return specs;
}
+LogString PatternLayout::getConversionPattern() const
+{
+ return m_priv->conversionPattern;
+}
+
diff --git a/src/main/cpp/socketoutputstream.cpp b/src/main/cpp/socketoutputstream.cpp
index 250ddd3..34fc06a 100644
--- a/src/main/cpp/socketoutputstream.cpp
+++ b/src/main/cpp/socketoutputstream.cpp
@@ -26,11 +26,17 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
+struct SocketOutputStream::SocketOutputStreamPrivate{
+ ByteList array;
+ SocketPtr socket;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(SocketOutputStream)
SocketOutputStream::SocketOutputStream(const SocketPtr& socket1)
- : socket(socket1)
+ : m_priv(std::make_unique<SocketOutputStreamPrivate>())
{
+ m_priv->socket = socket1;
}
SocketOutputStream::~SocketOutputStream()
@@ -40,16 +46,16 @@ SocketOutputStream::~SocketOutputStream()
void SocketOutputStream::close(Pool& p)
{
flush(p);
- socket->close();
+ m_priv->socket->close();
}
void SocketOutputStream::flush(Pool& /* p */)
{
- if (array.size() > 0)
+ if (m_priv->array.size() > 0)
{
- ByteBuffer buf((char*) &array[0], array.size());
- socket->write(buf);
- array.resize(0);
+ ByteBuffer buf((char*) &m_priv->array[0], m_priv->array.size());
+ m_priv->socket->write(buf);
+ m_priv->array.resize(0);
}
}
@@ -57,9 +63,9 @@ void SocketOutputStream::write(ByteBuffer& buf, Pool& /* p */ )
{
if (buf.remaining() > 0)
{
- size_t sz = array.size();
- array.resize(sz + buf.remaining());
- memcpy(&array[sz], buf.current(), buf.remaining());
+ size_t sz = m_priv->array.size();
+ m_priv->array.resize(sz + buf.remaining());
+ memcpy(&m_priv->array[sz], buf.current(), buf.remaining());
buf.position(buf.limit());
}
}
diff --git a/src/main/cpp/xmllayout.cpp b/src/main/cpp/xmllayout.cpp
index 1cdae41..2f8d7bd 100644
--- a/src/main/cpp/xmllayout.cpp
+++ b/src/main/cpp/xmllayout.cpp
@@ -32,13 +32,23 @@ using namespace log4cxx::helpers;
using namespace log4cxx::spi;
using namespace log4cxx::xml;
+struct XMLLayout::XMLLayoutPrivate{
+ XMLLayoutPrivate() : locationInfo(false), properties(false){}
+
+ // Print no location info by default
+ bool locationInfo; //= false
+ bool properties; // = false
+};
+
IMPLEMENT_LOG4CXX_OBJECT(XMLLayout)
XMLLayout::XMLLayout()
- : locationInfo(false), properties(false)
+ : m_priv(std::make_unique<XMLLayoutPrivate>())
{
}
+XMLLayout::~XMLLayout(){}
+
void XMLLayout::setOption(const LogString& option,
const LogString& value)
{
@@ -85,7 +95,7 @@ void XMLLayout::format(LogString& output,
output.append(LOG4CXX_EOL);
}
- if (locationInfo)
+ if (m_priv->locationInfo)
{
output.append(LOG4CXX_STR("<log4j:locationInfo class=\""));
const LocationInfo& locInfo = event->getLocationInformation();
@@ -103,7 +113,7 @@ void XMLLayout::format(LogString& output,
output.append(LOG4CXX_EOL);
}
- if (properties)
+ if (m_priv->properties)
{
LoggingEvent::KeySet propertySet(event->getPropertyKeySet());
LoggingEvent::KeySet keySet(event->getMDCKeySet());
@@ -159,3 +169,23 @@ void XMLLayout::format(LogString& output,
output.append(LOG4CXX_EOL);
}
+void XMLLayout::setLocationInfo(bool locationInfo1)
+{
+ m_priv->locationInfo = locationInfo1;
+}
+
+bool XMLLayout::getLocationInfo() const
+{
+ return m_priv->locationInfo;
+}
+
+void XMLLayout::setProperties(bool flag)
+{
+ m_priv->properties = flag;
+}
+
+bool XMLLayout::getProperties()
+{
+ return m_priv->properties;
+}
+
diff --git a/src/main/cpp/zipcompressaction.cpp b/src/main/cpp/zipcompressaction.cpp
index de0ac64..410710f 100644
--- a/src/main/cpp/zipcompressaction.cpp
+++ b/src/main/cpp/zipcompressaction.cpp
@@ -20,23 +20,38 @@
#include <apr_strings.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/transcoder.h>
+#include <log4cxx/private/action_priv.h>
using namespace log4cxx;
using namespace log4cxx::rolling;
using namespace log4cxx::helpers;
+#define priv static_cast<ZipCompressActionPrivate*>(m_priv.get())
+
+struct ZipCompressAction::ZipCompressActionPrivate : public ActionPrivate{
+ ZipCompressActionPrivate( const File& toRename,
+ const File& renameTo,
+ bool deleteSource):
+ source(toRename), destination(renameTo), deleteSource(deleteSource){}
+
+ const File source;
+ const File destination;
+ bool deleteSource;
+};
+
IMPLEMENT_LOG4CXX_OBJECT(ZipCompressAction)
ZipCompressAction::ZipCompressAction(const File& src,
const File& dest,
bool del)
- : source(src), destination(dest), deleteSource(del)
+ : Action(std::make_unique<ZipCompressActionPrivate>(
+ src, dest, del))
{
}
bool ZipCompressAction::execute(log4cxx::helpers::Pool& p) const
{
- if (!source.exists(p))
+ if (!priv->source.exists(p))
{
return false;
}
@@ -86,13 +101,13 @@ bool ZipCompressAction::execute(log4cxx::helpers::Pool& p) const
args[i++] = "zip";
args[i++] = "-q";
- args[i++] = Transcoder::encode(destination.getPath(), p);
- args[i++] = Transcoder::encode(source.getPath(), p);
+ args[i++] = Transcoder::encode(priv->destination.getPath(), p);
+ args[i++] = Transcoder::encode(priv->source.getPath(), p);
args[i++] = NULL;
- if (destination.exists(p))
+ if (priv->destination.exists(p))
{
- destination.deleteFile(p);
+ priv->destination.deleteFile(p);
}
apr_proc_t pid;
@@ -111,9 +126,9 @@ bool ZipCompressAction::execute(log4cxx::helpers::Pool& p) const
throw IOException(exitCode);
}
- if (deleteSource)
+ if (priv->deleteSource)
{
- source.deleteFile(p);
+ priv->source.deleteFile(p);
}
return true;
diff --git a/src/main/include/log4cxx/helpers/bufferedoutputstream.h b/src/main/include/log4cxx/helpers/bufferedoutputstream.h
deleted file mode 100644
index 0803da6..0000000
--- a/src/main/include/log4cxx/helpers/bufferedoutputstream.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_BUFFEREDOUTPUTSTREAM_H
-#define _LOG4CXX_HELPERS_BUFFEREDOUTPUTSTREAM_H
-
-#include <log4cxx/helpers/outputstream.h>
-
-namespace log4cxx
-{
-
-namespace helpers
-{
-
-/**
-* Abstract class for writing to character streams.
-*/
-class LOG4CXX_EXPORT BufferedOutputStream : public OutputStream
-{
- private:
- size_t count;
- LogString buf;
-
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(BufferedOutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(BufferedOutputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
- END_LOG4CXX_CAST_MAP()
-
- protected:
- BufferedOutputStream(OutputStreamPtr& out, size_t size = 4096);
- ~BufferedOutputStream();
-
- public:
- void close(Pool& p);
- void flush(Pool& p);
- void write(ByteBuffer& buf, Pool& p);
-
- private:
- BufferedOutputStream(const BufferedOutputStream&);
- BufferedOutputStream& operator=(const BufferedOutputStream&);
-};
-
-LOG4CXX_PTR_DEF(BufferedOutputStream);
-} // namespace helpers
-
-} //namespace log4cxx
-
-#endif //_LOG4CXX_HELPERS_BUFFEREDOUTPUTSTREAM_H
diff --git a/src/main/include/log4cxx/helpers/fileinputstream.h b/src/main/include/log4cxx/helpers/fileinputstream.h
index 613b33f..d088c4e 100644
--- a/src/main/include/log4cxx/helpers/fileinputstream.h
+++ b/src/main/include/log4cxx/helpers/fileinputstream.h
@@ -21,7 +21,7 @@
#include <log4cxx/helpers/inputstream.h>
#include <log4cxx/file.h>
#include <log4cxx/helpers/pool.h>
-
+#include <memory>
namespace log4cxx
{
@@ -36,8 +36,8 @@ namespace helpers
class LOG4CXX_EXPORT FileInputStream : public InputStream
{
private:
- Pool pool;
- apr_file_t* fileptr;
+ struct FileInputStreamPrivate;
+ std::unique_ptr<FileInputStreamPrivate> m_priv;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileInputStream)
diff --git a/src/main/include/log4cxx/helpers/fileoutputstream.h b/src/main/include/log4cxx/helpers/fileoutputstream.h
index cb03067..ddade3e 100644
--- a/src/main/include/log4cxx/helpers/fileoutputstream.h
+++ b/src/main/include/log4cxx/helpers/fileoutputstream.h
@@ -35,8 +35,8 @@ namespace helpers
class LOG4CXX_EXPORT FileOutputStream : public OutputStream
{
private:
- Pool pool;
- apr_file_t* fileptr;
+ struct FileOutputStreamPrivate;
+ std::unique_ptr<FileOutputStreamPrivate> m_priv;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileOutputStream)
diff --git a/src/main/include/log4cxx/helpers/socketoutputstream.h b/src/main/include/log4cxx/helpers/socketoutputstream.h
index 4cc9b8a..90000df 100644
--- a/src/main/include/log4cxx/helpers/socketoutputstream.h
+++ b/src/main/include/log4cxx/helpers/socketoutputstream.h
@@ -51,8 +51,8 @@ class LOG4CXX_EXPORT SocketOutputStream : public OutputStream
virtual void write(ByteBuffer& buf, Pool& p);
private:
- ByteList array;
- SocketPtr socket;
+ struct SocketOutputStreamPrivate;
+ std::unique_ptr<SocketOutputStreamPrivate> m_priv;
//
// prevent copy and assignment statements
SocketOutputStream(const SocketOutputStream&);
diff --git a/src/main/include/log4cxx/htmllayout.h b/src/main/include/log4cxx/htmllayout.h
index cc0e225..e7d8ac1 100644
--- a/src/main/include/log4cxx/htmllayout.h
+++ b/src/main/include/log4cxx/htmllayout.h
@@ -37,12 +37,8 @@ This layout outputs events in a HTML table.
class LOG4CXX_EXPORT HTMLLayout : public Layout
{
private:
- // Print no location info by default
- bool locationInfo; //= false
-
- LogString title;
-
- helpers::ISO8601DateFormat dateFormat;
+ struct HTMLLayoutPrivate;
+ std::unique_ptr<HTMLLayoutPrivate> m_priv;
public:
DECLARE_LOG4CXX_OBJECT(HTMLLayout)
@@ -64,44 +60,29 @@ class LOG4CXX_EXPORT HTMLLayout : public Layout
{@link net::SMTPAppender SMTPAppender} then make sure
to set the <b>LocationInfo</b> option of that appender as well.
*/
- inline void setLocationInfo(bool locationInfoFlag)
- {
- this->locationInfo = locationInfoFlag;
- }
+ void setLocationInfo(bool locationInfoFlag);
/**
Returns the current value of the <b>LocationInfo</b> option.
*/
- inline bool getLocationInfo() const
- {
- return locationInfo;
- }
+ bool getLocationInfo() const;
/**
The <b>Title</b> option takes a String value. This option sets the
document title of the generated HTML document.
<p>Defaults to 'Log4cxx Log Messages'.
*/
- inline void setTitle(const LogString& title1)
- {
- this->title.assign(title1);
- }
+ void setTitle(const LogString& title1);
/**
Returns the current value of the <b>Title</b> option.
*/
- inline const LogString& getTitle() const
- {
- return title;
- }
+ const LogString& getTitle() const;
/**
Returns the content type output by this layout, i.e "text/html".
*/
- virtual LogString getContentType() const
- {
- return LOG4CXX_STR("text/html");
- }
+ virtual LogString getContentType() const;
/**
No options to activate.
@@ -129,10 +110,7 @@ class LOG4CXX_EXPORT HTMLLayout : public Layout
/**
The HTML layout handles the throwable contained in logging
events. Hence, this method return <code>false</code>. */
- virtual bool ignoresThrowable() const
- {
- return false;
- }
+ bool ignoresThrowable() const;
}; // class HtmlLayout
LOG4CXX_PTR_DEF(HTMLLayout);
diff --git a/src/main/include/log4cxx/pattern/formattinginfo.h b/src/main/include/log4cxx/pattern/formattinginfo.h
index d78b985..66c472d 100644
--- a/src/main/include/log4cxx/pattern/formattinginfo.h
+++ b/src/main/include/log4cxx/pattern/formattinginfo.h
@@ -42,21 +42,8 @@ typedef std::shared_ptr<FormattingInfo> FormattingInfoPtr;
*/
class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::Object
{
-
- /**
- * Minimum length.
- */
- const int minLength;
-
- /**
- * Maximum length.
- */
- const int maxLength;
-
- /**
- * Alignment.
- */
- const bool leftAlign;
+ struct FormattingInfoPrivate;
+ std::unique_ptr<FormattingInfoPrivate> m_priv;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(FormattingInfo)
@@ -73,6 +60,7 @@ class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::Object
*/
FormattingInfo(
const bool leftAlign, const int minLength, const int maxLength);
+ ~FormattingInfo();
/**
* Gets default instance.
@@ -84,28 +72,19 @@ class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::Object
* Determine if left aligned.
* @return true if left aligned.
*/
- inline bool isLeftAligned() const
- {
- return leftAlign;
- }
+ bool isLeftAligned() const;
/**
* Get minimum length.
* @return minimum length.
*/
- inline int getMinLength() const
- {
- return minLength;
- }
+ int getMinLength() const;
/**
* Get maximum length.
* @return maximum length.
*/
- inline int getMaxLength() const
- {
- return maxLength;
- }
+ int getMaxLength() const;
/**
* Adjust the content of the buffer based on the specified lengths and alignment.
diff --git a/src/main/include/log4cxx/patternlayout.h b/src/main/include/log4cxx/patternlayout.h
index f722b5e..caae290 100644
--- a/src/main/include/log4cxx/patternlayout.h
+++ b/src/main/include/log4cxx/patternlayout.h
@@ -333,20 +333,8 @@ LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
*/
class LOG4CXX_EXPORT PatternLayout : public Layout
{
- /**
- * Conversion pattern.
- */
- LogString conversionPattern;
-
- /**
- * Pattern converters.
- */
- LoggingEventPatternConverterList patternConverters;
-
- /**
- * Field widths and alignment corresponding to pattern converters.
- */
- FormattingInfoList patternFields;
+ struct PatternLayoutPrivate;
+ std::unique_ptr<PatternLayoutPrivate> m_priv;
public:
DECLARE_LOG4CXX_OBJECT(PatternLayout)
@@ -365,6 +353,8 @@ class LOG4CXX_EXPORT PatternLayout : public Layout
*/
PatternLayout(const LogString& pattern);
+ ~PatternLayout();
+
/**
* Set the <strong>ConversionPattern</strong> option. This is the string which
* controls formatting and consists of a mix of literal content and
@@ -375,10 +365,7 @@ class LOG4CXX_EXPORT PatternLayout : public Layout
/**
* Returns the value of the <strong>ConversionPattern</strong> option.
*/
- inline LogString getConversionPattern() const
- {
- return conversionPattern;
- }
+ LogString getConversionPattern() const;
/**
* Call createPatternParser
diff --git a/src/main/cpp/defaultrepositoryselector.cpp b/src/main/include/log4cxx/private/action_priv.h
similarity index 63%
copy from src/main/cpp/defaultrepositoryselector.cpp
copy to src/main/include/log4cxx/private/action_priv.h
index 238e0ac..3fdb29a 100644
--- a/src/main/cpp/defaultrepositoryselector.cpp
+++ b/src/main/include/log4cxx/private/action_priv.h
@@ -14,20 +14,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#ifndef LOG4CXX_ACTION_PRIVATE_H
+#define LOG4CXX_ACTION_PRIVATE_H
-#include <log4cxx/spi/defaultrepositoryselector.h>
+#include <log4cxx/rolling/action.h>
-using namespace log4cxx;
-using namespace log4cxx::spi;
-using namespace log4cxx::helpers;
+namespace log4cxx{
+namespace rolling{
+struct Action::ActionPrivate{
+ ActionPrivate() :
+ complete(false),
+ interrupted(false),
+ pool(){}
-DefaultRepositorySelector::DefaultRepositorySelector(const LoggerRepositoryPtr repository1)
- : repository(repository1)
-{
-}
+ /**
+ * Is action complete.
+ */
+ bool complete;
+
+ /**
+ * Is action interrupted.
+ */
+ bool interrupted;
+
+ log4cxx::helpers::Pool pool;
+ std::mutex mutex;
+};
-LoggerRepositoryPtr DefaultRepositorySelector::getLoggerRepository()
-{
- return repository;
}
+}
+
+#endif /* LOG4CXX_ACTION_PRIVATE_H */
diff --git a/src/main/include/log4cxx/rolling/action.h b/src/main/include/log4cxx/rolling/action.h
index 31363d5..a69f326 100644
--- a/src/main/include/log4cxx/rolling/action.h
+++ b/src/main/include/log4cxx/rolling/action.h
@@ -39,14 +39,15 @@ class Action : public virtual log4cxx::helpers::Object
LOG4CXX_CAST_ENTRY(Action)
END_LOG4CXX_CAST_MAP()
- struct priv_data;
- std::unique_ptr<priv_data> m_priv;
+ struct ActionPrivate;
+ std::unique_ptr<ActionPrivate> m_priv;
protected:
/**
* Constructor.
*/
Action();
+ Action( std::unique_ptr<ActionPrivate> priv );
virtual ~Action();
public:
diff --git a/src/main/include/log4cxx/rolling/filerenameaction.h b/src/main/include/log4cxx/rolling/filerenameaction.h
index 53338a0..db80da6 100644
--- a/src/main/include/log4cxx/rolling/filerenameaction.h
+++ b/src/main/include/log4cxx/rolling/filerenameaction.h
@@ -29,9 +29,7 @@ namespace rolling
class FileRenameAction : public Action
{
- const File source;
- const File destination;
- bool renameEmptyFile;
+ struct FileRenameActionPrivate;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileRenameAction)
BEGIN_LOG4CXX_CAST_MAP()
diff --git a/src/main/include/log4cxx/rolling/gzcompressaction.h b/src/main/include/log4cxx/rolling/gzcompressaction.h
index 0b99f36..e087cb6 100644
--- a/src/main/include/log4cxx/rolling/gzcompressaction.h
+++ b/src/main/include/log4cxx/rolling/gzcompressaction.h
@@ -34,9 +34,7 @@ namespace rolling
class GZCompressAction : public Action
{
- const File source;
- const File destination;
- bool deleteSource;
+ struct GZCompressActionPrivate;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(GZCompressAction)
BEGIN_LOG4CXX_CAST_MAP()
@@ -50,6 +48,7 @@ class GZCompressAction : public Action
GZCompressAction(const File& source,
const File& destination,
bool deleteSource);
+ ~GZCompressAction();
/**
* Perform action.
diff --git a/src/main/include/log4cxx/rolling/zipcompressaction.h b/src/main/include/log4cxx/rolling/zipcompressaction.h
index 385b3df..bda9a9f 100644
--- a/src/main/include/log4cxx/rolling/zipcompressaction.h
+++ b/src/main/include/log4cxx/rolling/zipcompressaction.h
@@ -35,9 +35,7 @@ namespace rolling
class ZipCompressAction : public Action
{
- const File source;
- const File destination;
- bool deleteSource;
+ struct ZipCompressActionPrivate;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(ZipCompressAction)
BEGIN_LOG4CXX_CAST_MAP()
diff --git a/src/main/include/log4cxx/spi/defaultrepositoryselector.h b/src/main/include/log4cxx/spi/defaultrepositoryselector.h
index 8788b0d..1e22fed 100644
--- a/src/main/include/log4cxx/spi/defaultrepositoryselector.h
+++ b/src/main/include/log4cxx/spi/defaultrepositoryselector.h
@@ -21,6 +21,7 @@
#include <log4cxx/spi/repositoryselector.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/spi/loggerrepository.h>
+#include <memory>
namespace log4cxx
{
@@ -37,10 +38,12 @@ class LOG4CXX_EXPORT DefaultRepositorySelector :
END_LOG4CXX_CAST_MAP()
DefaultRepositorySelector(const LoggerRepositoryPtr repository1);
+ ~DefaultRepositorySelector();
virtual LoggerRepositoryPtr getLoggerRepository();
private:
- LoggerRepositoryPtr repository;
+ struct DefaultRepositorySelectorPrivate;
+ std::unique_ptr<DefaultRepositorySelectorPrivate> m_priv;
};
} // namespace spi
} // namespace log4cxx
diff --git a/src/main/include/log4cxx/varia/fallbackerrorhandler.h b/src/main/include/log4cxx/varia/fallbackerrorhandler.h
index 1f0f7e4..42395c3 100644
--- a/src/main/include/log4cxx/varia/fallbackerrorhandler.h
+++ b/src/main/include/log4cxx/varia/fallbackerrorhandler.h
@@ -42,9 +42,8 @@ class LOG4CXX_EXPORT FallbackErrorHandler :
public virtual helpers::Object
{
private:
- AppenderWeakPtr backup;
- AppenderWeakPtr primary;
- std::vector<LoggerPtr> loggers;
+ struct FallbackErrorHandlerPrivate;
+ std::unique_ptr<FallbackErrorHandlerPrivate> m_priv;
public:
DECLARE_LOG4CXX_OBJECT(FallbackErrorHandler)
@@ -54,6 +53,7 @@ class LOG4CXX_EXPORT FallbackErrorHandler :
END_LOG4CXX_CAST_MAP()
FallbackErrorHandler();
+ ~FallbackErrorHandler();
/**
<em>Adds</em> the logger passed as parameter to the list of
diff --git a/src/main/include/log4cxx/xml/domconfigurator.h b/src/main/include/log4cxx/xml/domconfigurator.h
index 98068aa..09b88c6 100644
--- a/src/main/include/log4cxx/xml/domconfigurator.h
+++ b/src/main/include/log4cxx/xml/domconfigurator.h
@@ -70,6 +70,9 @@ class LOG4CXX_EXPORT DOMConfigurator :
virtual public spi::Configurator,
virtual public helpers::Object
{
+public:
+ ~DOMConfigurator();
+
protected:
typedef std::map<LogString, AppenderPtr> AppenderMap;
/**
@@ -292,16 +295,14 @@ class LOG4CXX_EXPORT DOMConfigurator :
LogString subst(const LogString& value);
- protected:
- helpers::Properties props;
- spi::LoggerRepositoryPtr repository;
- spi::LoggerFactoryPtr loggerFactory;
-
private:
// prevent assignment or copy statements
DOMConfigurator(const DOMConfigurator&);
DOMConfigurator& operator=(const DOMConfigurator&);
static XMLWatchdog* xdog;
+
+ struct DOMConfiguratorPrivate;
+ std::unique_ptr<DOMConfiguratorPrivate> m_priv;
};
LOG4CXX_PTR_DEF(DOMConfigurator);
} // namespace xml
diff --git a/src/main/include/log4cxx/xml/xmllayout.h b/src/main/include/log4cxx/xml/xmllayout.h
index cff3e89..ffe0a13 100644
--- a/src/main/include/log4cxx/xml/xmllayout.h
+++ b/src/main/include/log4cxx/xml/xmllayout.h
@@ -53,10 +53,8 @@ appender where it is embedded.
class LOG4CXX_EXPORT XMLLayout : public Layout
{
private:
-
- // Print no location info by default
- bool locationInfo; //= false
- bool properties; // = false
+ struct XMLLayoutPrivate;
+ std::unique_ptr<XMLLayoutPrivate> m_priv;
public:
DECLARE_LOG4CXX_OBJECT(XMLLayout)
@@ -66,6 +64,7 @@ class LOG4CXX_EXPORT XMLLayout : public Layout
END_LOG4CXX_CAST_MAP()
XMLLayout();
+ ~XMLLayout();
/**
The <b>LocationInfo</b> option takes a boolean value. By
@@ -78,38 +77,26 @@ class LOG4CXX_EXPORT XMLLayout : public Layout
then make sure to set the
<b>LocationInfo</b> option of that appender as well.
*/
- inline void setLocationInfo(bool locationInfo1)
- {
- this->locationInfo = locationInfo1;
- }
+ void setLocationInfo(bool locationInfo1);
/**
Returns the current value of the <b>LocationInfo</b> option.
*/
- inline bool getLocationInfo() const
- {
- return locationInfo;
- }
+ bool getLocationInfo() const;
/**
* Sets whether MDC key-value pairs should be output, default false.
* @param flag new value.
*
*/
- inline void setProperties(bool flag)
- {
- properties = flag;
- }
+ void setProperties(bool flag);
/**
* Gets whether MDC key-value pairs should be output.
* @return true if MDC key-value pairs are output.
*
*/
- inline bool getProperties()
- {
- return properties;
- }
+ bool getProperties();
/** No options to activate. */