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 ) 30 #include <log4cxx/helpers/appenderattachableimpl.h> 31 #include <log4cxx/level.h> 32 #include <log4cxx/helpers/pool.h> 33 #include <log4cxx/helpers/mutex.h> 34 #include <log4cxx/spi/location/locationinfo.h> 35 #include <log4cxx/helpers/resourcebundle.h> 36 #include <log4cxx/helpers/messagebuffer.h> 49 class LoggerRepository;
50 LOG4CXX_PTR_DEF(LoggerRepository);
52 LOG4CXX_PTR_DEF(LoggerFactory);
57 LOG4CXX_PTR_DEF(Logger);
58 LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
70 DECLARE_ABSTRACT_LOG4CXX_OBJECT(
Logger)
71 BEGIN_LOG4CXX_CAST_MAP()
74 END_LOG4CXX_CAST_MAP()
109 helpers::AppenderAttachableImplPtr aai;
140 void releaseRef()
const;
149 virtual void addAppender(
const AppenderPtr& newAppender);
170 void closeNestedAppenders();
198 void debug(
const std::string& msg)
const;
199 #if LOG4CXX_WCHAR_T_API 226 void debug(
const std::wstring& msg)
const;
228 #if LOG4CXX_UNICHAR_API 255 void debug(
const std::basic_string<UniChar>& msg)
const;
257 #if LOG4CXX_CFSTRING_API 284 void debug(
const CFStringRef& msg)
const;
313 void error(
const std::string& msg)
const;
314 #if LOG4CXX_WCHAR_T_API 327 void error(
const std::wstring& msg)
const;
343 #if LOG4CXX_UNICHAR_API 370 void error(
const std::basic_string<UniChar>& msg)
const;
372 #if LOG4CXX_CFSTRING_API 399 void error(
const CFStringRef& msg)
const;
428 void fatal(
const std::string& msg)
const;
429 #if LOG4CXX_WCHAR_T_API 456 void fatal(
const std::wstring& msg)
const;
458 #if LOG4CXX_UNICHAR_API 485 void fatal(
const std::basic_string<UniChar>& msg)
const;
487 #if LOG4CXX_CFSTRING_API 514 void fatal(
const CFStringRef& msg)
const;
524 void forcedLog(
const LevelPtr& level,
const std::string& message,
532 void forcedLog(
const LevelPtr& level,
const std::string& message)
const;
534 #if LOG4CXX_WCHAR_T_API 542 void forcedLog(
const LevelPtr& level,
const std::wstring& message,
550 void forcedLog(
const LevelPtr& level,
const std::wstring& message)
const;
552 #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API 560 void forcedLog(
const LevelPtr& level,
const std::basic_string<UniChar>& message,
568 void forcedLog(
const LevelPtr& level,
const std::basic_string<UniChar>& message)
const;
570 #if LOG4CXX_CFSTRING_API 578 void forcedLog(
const LevelPtr& level,
const CFStringRef& message,
586 void forcedLog(
const LevelPtr& level,
const CFStringRef& message)
const;
595 void forcedLogLS(
const LevelPtr& level,
const LogString& message,
601 bool getAdditivity()
const;
608 AppenderList getAllAppenders()
const;
614 AppenderPtr getAppender(
const LogString& name)
const;
625 virtual const LevelPtr& getEffectiveLevel()
const;
646 void getName(std::string& name)
const;
647 #if LOG4CXX_WCHAR_T_API 652 void getName(std::wstring& name)
const;
654 #if LOG4CXX_UNICHAR_API 659 void getName(std::basic_string<UniChar>& name)
const;
661 #if LOG4CXX_CFSTRING_API 666 void getName(CFStringRef& name)
const;
689 static LoggerPtr getLogger(
const std::string& name);
694 static LoggerPtr getLogger(
const char*
const name);
695 #if LOG4CXX_WCHAR_T_API 700 static LoggerPtr getLogger(
const std::wstring& name);
705 static LoggerPtr getLogger(
const wchar_t*
const name);
707 #if LOG4CXX_UNICHAR_API 712 static LoggerPtr getLogger(
const std::basic_string<UniChar>& name);
714 #if LOG4CXX_CFSTRING_API 719 static LoggerPtr getLogger(
const CFStringRef& name);
725 static LoggerPtr getLoggerLS(
const LogString& name);
745 static LoggerPtr getLoggerLS(
const LogString& name,
760 static LoggerPtr getLogger(
const std::string& name,
762 #if LOG4CXX_WCHAR_T_API 776 static LoggerPtr getLogger(
const std::wstring& name,
779 #if LOG4CXX_UNICHAR_API 793 static LoggerPtr getLogger(
const std::basic_string<UniChar>& name,
796 #if LOG4CXX_CFSTRING_API 810 static LoggerPtr getLogger(
const CFStringRef& name,
823 helpers::ResourceBundlePtr getResourceBundle()
const;
835 LogString getResourceBundleString(
const LogString& key)
const;
852 void info(
const std::string& msg)
const;
853 #if LOG4CXX_WCHAR_T_API 880 void info(
const std::wstring& msg)
const;
882 #if LOG4CXX_UNICHAR_API 909 void info(
const std::basic_string<UniChar>& msg)
const;
911 #if LOG4CXX_CFSTRING_API 938 void info(
const CFStringRef& msg)
const;
944 bool isAttached(
const AppenderPtr& appender)
const;
980 bool isDebugEnabled()
const;
990 bool isEnabledFor(
const LevelPtr& level)
const;
1000 bool isInfoEnabled()
const;
1009 bool isWarnEnabled()
const;
1018 bool isErrorEnabled()
const;
1027 bool isFatalEnabled()
const;
1036 bool isTraceEnabled()
const;
1054 void l7dlog(
const LevelPtr& level,
const LogString& key,
1056 const std::vector<LogString>& values)
const;
1071 void l7dlog(
const LevelPtr& level,
const std::string& key,
1088 void l7dlog(
const LevelPtr& level,
const std::string& key,
1090 const std::string& val1)
const;
1107 void l7dlog(
const LevelPtr& level,
const std::string& key,
1109 const std::string& val1,
const std::string& val2)
const;
1127 void l7dlog(
const LevelPtr& level,
const std::string& key,
1129 const std::string& val1,
const std::string& val2,
const std::string& val3)
const;
1131 #if LOG4CXX_WCHAR_T_API 1146 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1163 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1165 const std::wstring& val1)
const;
1182 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1184 const std::wstring& val1,
const std::wstring& val2)
const;
1202 void l7dlog(
const LevelPtr& level,
const std::wstring& key,
1204 const std::wstring& val1,
const std::wstring& val2,
const std::wstring& val3)
const;
1206 #if LOG4CXX_UNICHAR_API 1221 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1238 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1240 const std::basic_string<UniChar>& val1)
const;
1257 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1259 const std::basic_string<UniChar>& val1,
const std::basic_string<UniChar>& val2)
const;
1277 void l7dlog(
const LevelPtr& level,
const std::basic_string<UniChar>& key,
1279 const std::basic_string<UniChar>& val1,
const std::basic_string<UniChar>& val2,
1280 const std::basic_string<UniChar>& val3)
const;
1282 #if LOG4CXX_CFSTRING_API 1297 void l7dlog(
const LevelPtr& level,
const CFStringRef& key,
1314 void l7dlog(
const LevelPtr& level,
const CFStringRef& key,
1316 const CFStringRef& val1)
const;
1333 void l7dlog(
const LevelPtr& level,
const CFStringRef& key,
1335 const CFStringRef& val1,
const CFStringRef& val2)
const;
1353 void l7dlog(
const LevelPtr& level,
const CFStringRef& key,
1355 const CFStringRef& val1,
const CFStringRef& val2,
1356 const CFStringRef& val3)
const;
1366 void log(
const LevelPtr& level,
const std::string& message,
1375 void log(
const LevelPtr& level,
const std::string& message)
const;
1376 #if LOG4CXX_WCHAR_T_API 1384 void log(
const LevelPtr& level,
const std::wstring& message,
1393 void log(
const LevelPtr& level,
const std::wstring& message)
const;
1395 #if LOG4CXX_UNICHAR_API 1403 void log(
const LevelPtr& level,
const std::basic_string<UniChar>& message,
1412 void log(
const LevelPtr& level,
const std::basic_string<UniChar>& message)
const;
1414 #if LOG4CXX_CFSTRING_API 1422 void log(
const LevelPtr& level,
const CFStringRef& message,
1431 void log(
const LevelPtr& level,
const CFStringRef& message)
const;
1440 void logLS(
const LevelPtr& level,
const LogString& message,
1450 void removeAllAppenders();
1461 void removeAppender(
const LogString& name);
1466 void setAdditivity(
bool additive);
1481 virtual void setLevel(
const LevelPtr& level);
1488 resourceBundle = bundle;
1491 #if LOG4CXX_WCHAR_T_API 1518 void warn(
const std::wstring& msg)
const;
1520 #if LOG4CXX_UNICHAR_API 1547 void warn(
const std::basic_string<UniChar>& msg)
const;
1549 #if LOG4CXX_CFSTRING_API 1576 void warn(
const CFStringRef& msg)
const;
1604 void warn(
const std::string& msg)
const;
1606 #if LOG4CXX_WCHAR_T_API 1633 void trace(
const std::wstring& msg)
const;
1635 #if LOG4CXX_UNICHAR_API 1662 void trace(
const std::basic_string<UniChar>& msg)
const;
1664 #if LOG4CXX_CFSTRING_API 1691 void trace(
const CFStringRef& msg)
const;
1719 void trace(
const std::string& msg)
const;
1721 inline SHARED_MUTEX& getMutex()
1731 mutable SHARED_MUTEX mutex;
1734 LOG4CXX_LIST_DEF(LoggerList,
LoggerPtr);
1742 #if !defined(LOG4CXX_UNLIKELY) 1750 #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0) 1758 #define LOG4CXX_UNLIKELY(expr) expr 1770 #define LOG4CXX_LOG(logger, level, message) do { \ 1771 if (logger->isEnabledFor(level)) {\ 1772 ::log4cxx::helpers::MessageBuffer oss_; \ 1773 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1782 #define LOG4CXX_LOGLS(logger, level, message) do { \ 1783 if (logger->isEnabledFor(level)) {\ 1784 ::log4cxx::helpers::LogCharMessageBuffer oss_; \ 1785 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1787 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000 1794 #define LOG4CXX_DEBUG(logger, message) do { \ 1795 if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\ 1796 ::log4cxx::helpers::MessageBuffer oss_; \ 1797 logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1799 #define LOG4CXX_DEBUG(logger, message) 1802 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000 1809 #define LOG4CXX_TRACE(logger, message) do { \ 1810 if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\ 1811 ::log4cxx::helpers::MessageBuffer oss_; \ 1812 logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1814 #define LOG4CXX_TRACE(logger, message) 1817 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000 1824 #define LOG4CXX_INFO(logger, message) do { \ 1825 if (logger->isInfoEnabled()) {\ 1826 ::log4cxx::helpers::MessageBuffer oss_; \ 1827 logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1829 #define LOG4CXX_INFO(logger, message) 1832 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000 1839 #define LOG4CXX_WARN(logger, message) do { \ 1840 if (logger->isWarnEnabled()) {\ 1841 ::log4cxx::helpers::MessageBuffer oss_; \ 1842 logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1844 #define LOG4CXX_WARN(logger, message) 1847 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000 1854 #define LOG4CXX_ERROR(logger, message) do { \ 1855 if (logger->isErrorEnabled()) {\ 1856 ::log4cxx::helpers::MessageBuffer oss_; \ 1857 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1866 #define LOG4CXX_ASSERT(logger, condition, message) do { \ 1867 if (!(condition) && logger->isErrorEnabled()) {\ 1868 ::log4cxx::helpers::MessageBuffer oss_; \ 1869 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1872 #define LOG4CXX_ERROR(logger, message) 1873 #define LOG4CXX_ASSERT(logger, condition, message) 1876 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000 1883 #define LOG4CXX_FATAL(logger, message) do { \ 1884 if (logger->isFatalEnabled()) {\ 1885 ::log4cxx::helpers::MessageBuffer oss_; \ 1886 logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0) 1888 #define LOG4CXX_FATAL(logger, message) 1898 #define LOG4CXX_L7DLOG(logger, level, key) do { \ 1899 if (logger->isEnabledFor(level)) {\ 1900 logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0) 1910 #define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \ 1911 if (logger->isEnabledFor(level)) {\ 1912 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0) 1923 #define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \ 1924 if (logger->isEnabledFor(level)) {\ 1925 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0) 1937 #define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \ 1938 if (logger->isEnabledFor(level)) {\ 1939 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0) 1943 #if defined(_MSC_VER) 1944 #pragma warning ( pop ) 1947 #include <log4cxx/spi/loggerrepository.h> 1949 #endif //_LOG4CXX_LOGGER_H A LoggerRepository is used to create and retrieve Loggers.
Definition: loggerrepository.h:47
This Interface is for attaching Appenders to objects.
Definition: appenderattachable.h:39
LogString name
The name of this logger.
Definition: logger.h:86
helpers::ResourceBundlePtr resourceBundle
The resourceBundle for localized messages.
Definition: logger.h:103
LoggerPtr parent
The parent of this logger.
Definition: logger.h:97
Implementation class for Object.
Definition: objectimpl.h:28
Definition: defaultloggerfactory.h:29
const LogString & getName() const
Get the logger name.
Definition: logger.h:638
LevelPtr level
The assigned level of this logger.
Definition: logger.h:92
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy...
Definition: hierarchy.h:55
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:118
utility class for objects multi-thread synchronization.
Definition: synchronized.h:33
This is the central class in the log4cxx package.
Definition: logger.h:65
Definition: appender.h:33
void setResourceBundle(const helpers::ResourceBundlePtr &bundle)
Set the resource bundle to be used with localized logging methods.
Definition: logger.h:1486