Skip to content

Commit

Permalink
Remove class DefaultLoggerFactory in the next ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Jul 14, 2024
1 parent 4232df4 commit bc0e9dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/main/cpp/defaultloggerfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
#if LOG4CXX_ABI_VERSION <= 15
#include <log4cxx/defaultloggerfactory.h>
#else
#include <log4cxx/loggerfactory.h>
#include <log4cxx/spi/loggerfactory.h>
#endif

using namespace LOG4CXX_NS;

LoggerPtr spi::LoggerFactory::makeNewLoggerInstance(const LogString& name) const
{
return std::make_shared<Logger>(name);
}
using namespace spi;

#if LOG4CXX_ABI_VERSION <= 15
IMPLEMENT_LOG4CXX_OBJECT(DefaultLoggerFactory)
Expand All @@ -38,3 +34,9 @@ LoggerPtr DefaultLoggerFactory::makeNewLoggerInstance(
return std::make_shared<Logger>(name);
}
#endif

LoggerPtr LoggerFactory::makeNewLoggerInstance(const LogString& name) const
{
return std::make_shared<Logger>(name);
}

2 changes: 1 addition & 1 deletion src/main/cpp/domconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#if LOG4CXX_ABI_VERSION <= 15
#include <log4cxx/defaultloggerfactory.h>
#else
#include <log4cxx/loggerfactory.h>
#include <log4cxx/spi/loggerfactory.h>
#endif
#include <log4cxx/helpers/filewatchdog.h>
#include <log4cxx/spi/loggerrepository.h>
Expand Down
10 changes: 9 additions & 1 deletion src/main/cpp/hierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ LevelPtr Hierarchy::getThreshold() const

LoggerPtr Hierarchy::getLogger(const LogString& name)
{
#if LOG4CXX_ABI_VERSION <= 15
static WideLife<spi::LoggerFactoryPtr> defaultFactory = std::make_shared<DefaultLoggerFactory>();
#else
static WideLife<spi::LoggerFactoryPtr> defaultFactory = std::make_shared<LoggerFactory>();
#endif
return getLogger(name, defaultFactory);
}

Expand All @@ -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));

Expand Down Expand Up @@ -283,7 +291,7 @@ LoggerPtr Hierarchy::getRootLogger() const
std::lock_guard<std::recursive_mutex> lock(m_priv->mutex);
if (!m_priv->root)
{
m_priv->root = std::make_shared<RootLogger>(m_priv->pool, Level::getDebug());
m_priv->root = std::make_shared<RootLogger>(Level::getDebug());
m_priv->root->setHierarchy(const_cast<Hierarchy*>(this));
}

Expand Down
9 changes: 8 additions & 1 deletion src/main/include/log4cxx/spi/loggerfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc0e9dd

Please sign in to comment.