18#ifndef LOG4CXX_LOGGER_INSTANCE_HDR_
19#define LOG4CXX_LOGGER_INSTANCE_HDR_
48 bool m_hadConfiguration;
55 template <
class StringType>
57 : m_hadConfiguration(
LogManager::exists(instanceName))
58 , m_logger(
LogManager::getLogger(instanceName))
72 explicit operator bool() const noexcept
89 return m_logger.get();
94 return m_logger.get();
100 if (m_logger && !m_hadConfiguration)
102 auto name = m_logger->getName();
104 LogManager::removeLogger(name);
108 m_hadConfiguration =
false;
114 template <
class StringType>
115 void reset(
const StringType& instanceName)
118 m_hadConfiguration = !!LogManager::exists(instanceName);
119 m_logger = LogManager::getLogger(instanceName);
Use the LogManager class to retreive Logger instances or to operate on the current LoggerRepository.
Definition: logmanager.h:45
A smart pointer (implicity convertable to LoggerPtr) that conditionally removes a Logger from the spi...
Definition: loggerinstance.h:47
LoggerInstancePtr(const StringType &instanceName)
A separately configurable logger named instanceName.
Definition: loggerinstance.h:56
Logger * get() noexcept
Definition: loggerinstance.h:87
const Logger * get() const noexcept
Definition: loggerinstance.h:92
void reset(const StringType &instanceName)
Change this to a logger named instanceName.
Definition: loggerinstance.h:115
LoggerInstancePtr()
A null LoggerPtr.
Definition: loggerinstance.h:52
const LoggerPtr & operator->() const noexcept
Definition: loggerinstance.h:67
~LoggerInstancePtr()
Conditionally remove the logger from the the spi::LoggerRepository.
Definition: loggerinstance.h:62
void reset()
Conditionally remove the Logger from the spi::LoggerRepository.
Definition: loggerinstance.h:98
This is the central class in the log4cxx package.
Definition: log4cxx/logger.h:51
#define LOG4CXX_NS
Definition: log4cxx.h:104
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:27