18 #ifndef _LOG4CXX_LOGGER_H 19 #define _LOG4CXX_LOGGER_H 21 #if defined(_MSC_VER) && (_MSC_VER < 1900) 22 #pragma warning ( push ) 23 #pragma warning ( disable: 4127 ) 26 #pragma warning ( push ) 27 #pragma warning ( disable: 4231 4251 4275 4786 ) 47 class LoggerRepository;
107 helpers::AppenderAttachableImplPtr
aai;
144 virtual void addAppender(
const AppenderPtr newAppender);
165 void closeNestedAppenders();
193 void debug(
const std::string& msg)
const;
194 #if LOG4CXX_WCHAR_T_API 221 void debug(
const std::wstring& msg)
const;
223 #if LOG4CXX_UNICHAR_API 250 void debug(
const std::basic_string<UniChar>& msg)
const;
252 #if LOG4CXX_CFSTRING_API 308 void error(
const std::string& msg)
const;
309 #if LOG4CXX_WCHAR_T_API 322 void error(
const std::wstring& msg)
const;
338 #if LOG4CXX_UNICHAR_API 365 void error(
const std::basic_string<UniChar>& msg)
const;
367 #if LOG4CXX_CFSTRING_API 423 void fatal(
const std::string& msg)
const;
424 #if LOG4CXX_WCHAR_T_API 451 void fatal(
const std::wstring& msg)
const;
453 #if LOG4CXX_UNICHAR_API 480 void fatal(
const std::basic_string<UniChar>& msg)
const;
482 #if LOG4CXX_CFSTRING_API 519 void forcedLog(
const LevelPtr& level,
const std::string& message,
527 void forcedLog(
const LevelPtr& level,
const std::string& message)
const;
529 #if LOG4CXX_WCHAR_T_API 537 void forcedLog(
const LevelPtr& level,
const std::wstring& message,
545 void forcedLog(
const LevelPtr& level,
const std::wstring& message)
const;
547 #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API 555 void forcedLog(
const LevelPtr& level,
const std::basic_string<UniChar>& message,
563 void forcedLog(
const LevelPtr& level,
const std::basic_string<UniChar>& message)
const;
565 #if LOG4CXX_CFSTRING_API 596 bool getAdditivity()
const;
603 AppenderList getAllAppenders()
const;
620 virtual const LevelPtr getEffectiveLevel()
const;
626 log4cxx::spi::LoggerRepositoryWeakPtr getLoggerRepository()
const;
641 void getName(std::string& name)
const;
642 #if LOG4CXX_WCHAR_T_API 647 void getName(std::wstring& name)
const;
649 #if LOG4CXX_UNICHAR_API 654 void getName(std::basic_string<UniChar>& name)
const;
656 #if LOG4CXX_CFSTRING_API 684 static LoggerPtr getLogger(
const std::string& name);
689 static LoggerPtr getLogger(
const char*
const name);
690 #if LOG4CXX_WCHAR_T_API 695 static LoggerPtr getLogger(
const std::wstring& name);
700 static LoggerPtr getLogger(
const wchar_t*
const name);
702 #if LOG4CXX_UNICHAR_API 707 static LoggerPtr getLogger(
const std::basic_string<UniChar>& name);
709 #if LOG4CXX_CFSTRING_API 755 static LoggerPtr getLogger(
const std::string& name,
757 #if LOG4CXX_WCHAR_T_API 771 static LoggerPtr getLogger(
const std::wstring& name,
774 #if LOG4CXX_UNICHAR_API 788 static LoggerPtr getLogger(
const std::basic_string<UniChar>& name,
791 #if LOG4CXX_CFSTRING_API 818 helpers::ResourceBundlePtr getResourceBundle()
const;
847 void info(
const std::string& msg)
const;
848 #if LOG4CXX_WCHAR_T_API 875 void info(
const std::wstring& msg)
const;
877 #if LOG4CXX_UNICHAR_API 904 void info(
const std::basic_string<UniChar>& msg)
const;
906 #if LOG4CXX_CFSTRING_API 975 bool isDebugEnabled()
const;
985 bool isEnabledFor(
const LevelPtr& level)
const;
995 bool isInfoEnabled()
const;
1004 bool isWarnEnabled()
const;
1013 bool isErrorEnabled()
const;
1022 bool isFatalEnabled()
const;
1031 bool isTraceEnabled()
const;
1051 const std::vector<LogString>& values)
const;
1066 void l7dlog(
const LevelPtr& level,
const std::string& key,
1083 void l7dlog(
const LevelPtr& level,
const std::string& key,
1085 const std::string& val1)
const;
1102 void l7dlog(
const LevelPtr& level,
const std::string& key,
1104 const std::string& val1,
const std::string& val2)
const;
1122 void l7dlog(
const LevelPtr& level,
const std::string& key,
1124 const std::string& val1,
const std::string& val2,
const std::string& val3)
const;
1126 #if LOG4CXX_WCHAR_T_API 1141 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1158 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1160 const std::wstring& val1)
const;
1177 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1179 const std::wstring& val1,
const std::wstring& val2)
const;
1197 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1199 const std::wstring& val1,
const std::wstring& val2,
const std::wstring& val3)
const;
1201 #if LOG4CXX_UNICHAR_API 1216 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1233 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1235 const std::basic_string<UniChar>& val1)
const;
1252 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1254 const std::basic_string<UniChar>& val1,
const std::basic_string<UniChar>& val2)
const;
1272 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1274 const std::basic_string<UniChar>& val1,
const std::basic_string<UniChar>& val2,
1275 const std::basic_string<UniChar>& val3)
const;
1277 #if LOG4CXX_CFSTRING_API 1361 void log(
const LevelPtr& level,
const std::string& message,
1370 void log(
const LevelPtr& level,
const std::string& message)
const;
1371 #if LOG4CXX_WCHAR_T_API 1379 void log(
const LevelPtr& level,
const std::wstring& message,
1388 void log(
const LevelPtr& level,
const std::wstring& message)
const;
1390 #if LOG4CXX_UNICHAR_API 1398 void log(
const LevelPtr& level,
const std::basic_string<UniChar>& message,
1407 void log(
const LevelPtr& level,
const std::basic_string<UniChar>& message)
const;
1409 #if LOG4CXX_CFSTRING_API 1445 void removeAllAppenders();
1456 void removeAppender(
const LogString& name);
1461 void setAdditivity(
bool additive);
1467 void setHierarchy(spi::LoggerRepositoryWeakPtr repository);
1476 virtual void setLevel(
const LevelPtr level);
1483 resourceBundle = bundle;
1486 #if LOG4CXX_WCHAR_T_API 1513 void warn(
const std::wstring& msg)
const;
1515 #if LOG4CXX_UNICHAR_API 1542 void warn(
const std::basic_string<UniChar>& msg)
const;
1544 #if LOG4CXX_CFSTRING_API 1599 void warn(
const std::string& msg)
const;
1601 #if LOG4CXX_WCHAR_T_API 1628 void trace(
const std::wstring& msg)
const;
1630 #if LOG4CXX_UNICHAR_API 1657 void trace(
const std::basic_string<UniChar>& msg)
const;
1659 #if LOG4CXX_CFSTRING_API 1714 void trace(
const std::string& msg)
const;
1722 void reconfigure(
const std::vector<AppenderPtr>& appenders,
bool additivity );
1729 mutable shared_mutex mutex;
1730 friend class log4cxx::helpers::synchronized;
1740 #if !defined(LOG4CXX_UNLIKELY) 1748 #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0) 1756 #define LOG4CXX_UNLIKELY(expr) expr 1768 #define LOG4CXX_LOG(logger, level, message) do { \ 1769 if (logger->isEnabledFor(level)) {\ 1770 ::log4cxx::helpers::MessageBuffer oss_; \ 1771 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1780 #define LOG4CXX_LOG_FMT(logger, level, ...) do { \ 1781 if (logger->isEnabledFor(level)) {\ 1782 logger->forcedLog(level, fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1791 #define LOG4CXX_LOGLS(logger, level, message) do { \ 1792 if (logger->isEnabledFor(level)) {\ 1793 ::log4cxx::helpers::LogCharMessageBuffer oss_; \ 1794 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1796 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000 1803 #define LOG4CXX_DEBUG(logger, message) do { \ 1804 if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\ 1805 ::log4cxx::helpers::MessageBuffer oss_; \ 1806 logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1814 #define LOG4CXX_DEBUG_FMT(logger, ...) do { \ 1815 if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\ 1816 logger->forcedLog(::log4cxx::Level::getDebug(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1818 #define LOG4CXX_DEBUG(logger, message) 1819 #define LOG4CXX_DEBUG_FMT(logger, ...) 1822 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000 1829 #define LOG4CXX_TRACE(logger, message) do { \ 1830 if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\ 1831 ::log4cxx::helpers::MessageBuffer oss_; \ 1832 logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1840 #define LOG4CXX_TRACE_FMT(logger, ...) do { \ 1841 if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\ 1842 logger->forcedLog(::log4cxx::Level::getTrace(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1844 #define LOG4CXX_TRACE(logger, message) 1845 #define LOG4CXX_TRACE_FMT(logger, ...) 1848 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000 1855 #define LOG4CXX_INFO(logger, message) do { \ 1856 if (logger->isInfoEnabled()) {\ 1857 ::log4cxx::helpers::MessageBuffer oss_; \ 1858 logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1867 #define LOG4CXX_INFO_FMT(logger, ...) do { \ 1868 if (logger->isInfoEnabled()) {\ 1869 logger->forcedLog(::log4cxx::Level::getInfo(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1871 #define LOG4CXX_INFO(logger, message) 1872 #define LOG4CXX_INFO_FMT(logger, ...) 1875 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000 1882 #define LOG4CXX_WARN(logger, message) do { \ 1883 if (logger->isWarnEnabled()) {\ 1884 ::log4cxx::helpers::MessageBuffer oss_; \ 1885 logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1893 #define LOG4CXX_WARN_FMT(logger, ...) do { \ 1894 if (logger->isWarnEnabled()) {\ 1895 logger->forcedLog(::log4cxx::Level::getWarn(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1897 #define LOG4CXX_WARN(logger, message) 1898 #define LOG4CXX_WARN_FMT(logger, ...) 1901 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000 1908 #define LOG4CXX_ERROR(logger, message) do { \ 1909 if (logger->isErrorEnabled()) {\ 1910 ::log4cxx::helpers::MessageBuffer oss_; \ 1911 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1919 #define LOG4CXX_ERROR_FMT(logger, ...) do { \ 1920 if (logger->isErrorEnabled()) {\ 1921 logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1930 #define LOG4CXX_ASSERT(logger, condition, message) do { \ 1931 if (!(condition) && logger->isErrorEnabled()) {\ 1932 ::log4cxx::helpers::MessageBuffer oss_; \ 1933 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1942 #define LOG4CXX_ASSERT_FMT(logger, condition, ...) do { \ 1943 if (!(condition) && logger->isErrorEnabled()) {\ 1944 logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1947 #define LOG4CXX_ERROR(logger, message) 1948 #define LOG4CXX_ERROR_FMT(logger, ...) 1949 #define LOG4CXX_ASSERT(logger, condition, message) 1950 #define LOG4CXX_ASSERT_FMT(logger, condition, ...) 1953 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000 1960 #define LOG4CXX_FATAL(logger, message) do { \ 1961 if (logger->isFatalEnabled()) {\ 1962 ::log4cxx::helpers::MessageBuffer oss_; \ 1963 logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1971 #define LOG4CXX_FATAL_FMT(logger, ...) do { \ 1972 if (logger->isFatalEnabled()) {\ 1973 logger->forcedLog(::log4cxx::Level::getFatal(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0) 1975 #define LOG4CXX_FATAL(logger, message) 1976 #define LOG4CXX_FATAL_FMT(logger, ...) 1986 #define LOG4CXX_L7DLOG(logger, level, key) do { \ 1987 if (logger->isEnabledFor(level)) {\ 1988 logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0) 1998 #define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \ 1999 if (logger->isEnabledFor(level)) {\ 2000 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0) 2011 #define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \ 2012 if (logger->isEnabledFor(level)) {\ 2013 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0) 2025 #define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \ 2026 if (logger->isEnabledFor(level)) {\ 2027 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0) 2031 #if defined(_MSC_VER) 2032 #pragma warning ( pop ) 2037 #endif //_LOG4CXX_LOGGER_H #define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:38
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:27
LOG4CXX_PTR_DEF(AppenderAttachableImpl)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
This Interface is for attaching Appenders to objects.
Definition: appenderattachable.h:38
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
std::vector< LoggerPtr > LoggerList
Definition: logmanager.h:34
LOG4CXX_LIST_DEF(ByteList, unsigned char)
const struct __CFString * CFStringRef
Definition: logstring.h:36
LogString name
The name of this logger.
Definition: logger.h:84
helpers::ResourceBundlePtr resourceBundle
The resourceBundle for localized messages.
Definition: logger.h:101
LoggerPtr parent
The parent of this logger.
Definition: logger.h:95
base class for java-like objects.
Definition: object.h:101
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:28
Definition: defaultloggerfactory.h:29
const LogString & getName() const
Get the logger name.
Definition: logger.h:633
LevelPtr level
The assigned level of this logger.
Definition: logger.h:90
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy...
Definition: hierarchy.h:59
helpers::AppenderAttachableImplPtr aai
Definition: logger.h:107
This class represents the location of a logging statement.
Definition: locationinfo.h:33
bool additive
Additivity is set to true by default, that is children inherit the appenders of their ancestors by de...
Definition: logger.h:116
log4cxx::spi::LoggerRepositoryWeakPtr repository
Definition: logger.h:105
This is the central class in the log4cxx package.
Definition: logger.h:63
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:26
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
void setResourceBundle(const helpers::ResourceBundlePtr &bundle)
Set the resource bundle to be used with localized logging methods.
Definition: logger.h:1481