From bc0e9dd4019f582983c7f1a760e0a882921f5fed Mon Sep 17 00:00:00 2001 From: Stephen Webb Date: Sun, 14 Jul 2024 13:20:06 +1000 Subject: [PATCH] Remove class DefaultLoggerFactory in the next ABI --- src/main/cpp/defaultloggerfactory.cpp | 14 ++++++++------ src/main/cpp/domconfigurator.cpp | 2 +- src/main/cpp/hierarchy.cpp | 10 +++++++++- src/main/include/log4cxx/spi/loggerfactory.h | 9 ++++++++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/cpp/defaultloggerfactory.cpp b/src/main/cpp/defaultloggerfactory.cpp index fe4f38851..1831e0bcc 100644 --- a/src/main/cpp/defaultloggerfactory.cpp +++ b/src/main/cpp/defaultloggerfactory.cpp @@ -18,15 +18,11 @@ #if LOG4CXX_ABI_VERSION <= 15 #include #else -#include +#include #endif using namespace LOG4CXX_NS; - -LoggerPtr spi::LoggerFactory::makeNewLoggerInstance(const LogString& name) const -{ - return std::make_shared(name); -} +using namespace spi; #if LOG4CXX_ABI_VERSION <= 15 IMPLEMENT_LOG4CXX_OBJECT(DefaultLoggerFactory) @@ -38,3 +34,9 @@ LoggerPtr DefaultLoggerFactory::makeNewLoggerInstance( return std::make_shared(name); } #endif + +LoggerPtr LoggerFactory::makeNewLoggerInstance(const LogString& name) const +{ + return std::make_shared(name); +} + diff --git a/src/main/cpp/domconfigurator.cpp b/src/main/cpp/domconfigurator.cpp index 55618907a..954a8bb2c 100644 --- a/src/main/cpp/domconfigurator.cpp +++ b/src/main/cpp/domconfigurator.cpp @@ -33,7 +33,7 @@ #if LOG4CXX_ABI_VERSION <= 15 #include #else -#include +#include #endif #include #include diff --git a/src/main/cpp/hierarchy.cpp b/src/main/cpp/hierarchy.cpp index 9e8f8295e..b11ace087 100644 --- a/src/main/cpp/hierarchy.cpp +++ b/src/main/cpp/hierarchy.cpp @@ -227,7 +227,11 @@ LevelPtr Hierarchy::getThreshold() const LoggerPtr Hierarchy::getLogger(const LogString& name) { +#if LOG4CXX_ABI_VERSION <= 15 static WideLife defaultFactory = std::make_shared(); +#else + static WideLife defaultFactory = std::make_shared(); +#endif return getLogger(name, defaultFactory); } @@ -246,7 +250,11 @@ LoggerPtr Hierarchy::getLogger(const LogString& name, } if (!result && factory) { +#if LOG4CXX_ABI_VERSION <= 15 + LoggerPtr logger(factory->makeNewLoggerInstance(m_priv->pool, name)); +#else LoggerPtr logger(factory->makeNewLoggerInstance(name)); +#endif logger->setHierarchy(this); m_priv->loggers.insert(LoggerMap::value_type(name, logger)); @@ -283,7 +291,7 @@ LoggerPtr Hierarchy::getRootLogger() const std::lock_guard lock(m_priv->mutex); if (!m_priv->root) { - m_priv->root = std::make_shared(m_priv->pool, Level::getDebug()); + m_priv->root = std::make_shared(Level::getDebug()); m_priv->root->setHierarchy(const_cast(this)); } diff --git a/src/main/include/log4cxx/spi/loggerfactory.h b/src/main/include/log4cxx/spi/loggerfactory.h index bf9b4a9a7..b3d1e31c7 100644 --- a/src/main/include/log4cxx/spi/loggerfactory.h +++ b/src/main/include/log4cxx/spi/loggerfactory.h @@ -32,13 +32,20 @@ a sub-class of Logger. class LOG4CXX_EXPORT LoggerFactory : public virtual helpers::Object { public: +#if LOG4CXX_ABI_VERSION <= 15 DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory) +#else + DECLARE_LOG4CXX_OBJECT(LoggerFactory) + BEGIN_LOG4CXX_CAST_MAP() + LOG4CXX_CAST_ENTRY(LoggerFactory) + END_LOG4CXX_CAST_MAP() +#endif virtual ~LoggerFactory() {} #if LOG4CXX_ABI_VERSION <= 15 LoggerPtr makeNewLoggerInstance(const LogString& name) const; #else - virtual LoggerPtr makeNewLoggerInstance(const LogString& name) const = 0; + virtual LoggerPtr makeNewLoggerInstance(const LogString& name) const; #endif #if LOG4CXX_ABI_VERSION <= 15