Apache Log4cxx Version 1.1.0
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_LOGGER_H
19#define _LOG4CXX_LOGGER_H
20
22#include <log4cxx/level.h>
27
28namespace log4cxx
29{
30
31namespace spi
32{
33class LoggerRepository;
35class LoggerFactory;
37}
38
39class Logger;
43
44
49class LOG4CXX_EXPORT Logger :
51{
52 public:
58
59 private:
60 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(LoggerPrivate, m_priv)
61 int m_threshold;
62
63 public:
73 Logger(helpers::Pool& pool, const LogString& name);
74
76
77
85 void addAppender(const AppenderPtr newAppender) override;
86
87
101
107
121 void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
136 void debug(const std::string& msg) const;
137#if LOG4CXX_WCHAR_T_API
153 void debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
168 void debug(const std::wstring& msg) const;
169#endif
170#if LOG4CXX_UNICHAR_API
186 void debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
201 void debug(const std::basic_string<UniChar>& msg) const;
202#endif
203#if LOG4CXX_CFSTRING_API
219 void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
234 void debug(const CFStringRef& msg) const;
235#endif
236
252 void error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
267 void error(const std::string& msg) const;
268#if LOG4CXX_WCHAR_T_API
283 void error(const std::wstring& msg) const;
299 void error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
300#endif
301#if LOG4CXX_UNICHAR_API
317 void error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
332 void error(const std::basic_string<UniChar>& msg) const;
333#endif
334#if LOG4CXX_CFSTRING_API
350 void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
365 void error(const CFStringRef& msg) const;
366#endif
367
383 void fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
398 void fatal(const std::string& msg) const;
399#if LOG4CXX_WCHAR_T_API
415 void fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
430 void fatal(const std::wstring& msg) const;
431#endif
432#if LOG4CXX_UNICHAR_API
448 void fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
463 void fatal(const std::basic_string<UniChar>& msg) const;
464#endif
465#if LOG4CXX_CFSTRING_API
481 void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
496 void fatal(const CFStringRef& msg) const;
497#endif
498
506 void forcedLog(const LevelPtr& level, const std::string& message,
507 const log4cxx::spi::LocationInfo& location) const;
514 void forcedLog(const LevelPtr& level, const std::string& message) const;
515
516#if LOG4CXX_WCHAR_T_API
524 void forcedLog(const LevelPtr& level, const std::wstring& message,
525 const log4cxx::spi::LocationInfo& location) const;
532 void forcedLog(const LevelPtr& level, const std::wstring& message) const;
533#endif
534#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
542 void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
543 const log4cxx::spi::LocationInfo& location) const;
550 void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
551#endif
552#if LOG4CXX_CFSTRING_API
560 void forcedLog(const LevelPtr& level, const CFStringRef& message,
561 const log4cxx::spi::LocationInfo& location) const;
568 void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
569#endif
577 void forcedLogLS(const LevelPtr& level, const LogString& message,
578 const log4cxx::spi::LocationInfo& location) const;
579
583 bool getAdditivity() const;
584
590 AppenderList getAllAppenders() const override;
591
596 AppenderPtr getAppender(const LogString& name) const override;
597
607 virtual const LevelPtr& getEffectiveLevel() const;
608
614
615
620 const LogString& getName() const;
621
626 void getName(std::string& name) const;
627#if LOG4CXX_WCHAR_T_API
632 void getName(std::wstring& name) const;
633#endif
634#if LOG4CXX_UNICHAR_API
639 void getName(std::basic_string<UniChar>& name) const;
640#endif
641#if LOG4CXX_CFSTRING_API
646 void getName(CFStringRef& name) const;
647#endif
648
656
657
663 const LevelPtr& getLevel() const;
664
669 static LoggerPtr getLogger(const std::string& name);
674 static LoggerPtr getLogger(const char* const name);
675#if LOG4CXX_WCHAR_T_API
680 static LoggerPtr getLogger(const std::wstring& name);
685 static LoggerPtr getLogger(const wchar_t* const name);
686#endif
687#if LOG4CXX_UNICHAR_API
692 static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
693#endif
694#if LOG4CXX_CFSTRING_API
699 static LoggerPtr getLogger(const CFStringRef& name);
700#endif
705 static LoggerPtr getLoggerLS(const LogString& name);
706
711
725 static LoggerPtr getLoggerLS(const LogString& name,
726 const log4cxx::spi::LoggerFactoryPtr& factory);
740 static LoggerPtr getLogger(const std::string& name,
741 const log4cxx::spi::LoggerFactoryPtr& factory);
742#if LOG4CXX_WCHAR_T_API
756 static LoggerPtr getLogger(const std::wstring& name,
757 const log4cxx::spi::LoggerFactoryPtr& factory);
758#endif
759#if LOG4CXX_UNICHAR_API
773 static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
774 const log4cxx::spi::LoggerFactoryPtr& factory);
775#endif
776#if LOG4CXX_CFSTRING_API
790 static LoggerPtr getLogger(const CFStringRef& name,
791 const log4cxx::spi::LoggerFactoryPtr& factory);
792#endif
793
803 helpers::ResourceBundlePtr getResourceBundle() const;
804
805 protected:
816
817 public:
833 void info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
848 void info(const std::string& msg) const;
849#if LOG4CXX_WCHAR_T_API
865 void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
880 void info(const std::wstring& msg) const;
881#endif
882#if LOG4CXX_UNICHAR_API
896 void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
911 void info(const std::basic_string<UniChar>& msg) const;
912#endif
913#if LOG4CXX_CFSTRING_API
929 void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
944 void info(const CFStringRef& msg) const;
945#endif
946
950 bool isAttached(const AppenderPtr appender) const override;
951
986 bool isDebugEnabled() const;
987
1009 inline static bool isDebugEnabledFor(const LoggerPtr& logger)
1010 {
1011 return logger && logger->m_threshold <= Level::DEBUG_INT && logger->isDebugEnabled();
1012 }
1013
1019 bool isEnabledFor(const LevelPtr& level) const;
1020
1021
1031 bool isInfoEnabled() const;
1032
1043 inline static bool isInfoEnabledFor(const LoggerPtr& logger)
1044 {
1045 return logger && logger->m_threshold <= Level::INFO_INT && logger->isInfoEnabled();
1046 }
1047
1057 bool isWarnEnabled() const;
1058
1069 inline static bool isWarnEnabledFor(const LoggerPtr& logger)
1070 {
1071 return logger && logger->m_threshold <= Level::WARN_INT && logger->isWarnEnabled();
1072 }
1073
1083 bool isErrorEnabled() const;
1084
1095 inline static bool isErrorEnabledFor(const LoggerPtr& logger)
1096 {
1097 return logger && logger->m_threshold <= Level::ERROR_INT && logger->isErrorEnabled();
1098 }
1099
1109 bool isFatalEnabled() const;
1110
1121 inline static bool isFatalEnabledFor(const LoggerPtr& logger)
1122 {
1123 return logger && logger->m_threshold <= Level::FATAL_INT && logger->isFatalEnabled();
1124 }
1125
1135 bool isTraceEnabled() const;
1136
1147 inline static bool isTraceEnabledFor(const LoggerPtr& logger)
1148 {
1149 return logger && logger->m_threshold <= Level::TRACE_INT && logger->isTraceEnabled();
1150 }
1151
1170 void l7dlog(const LevelPtr& level, const LogString& key,
1171 const log4cxx::spi::LocationInfo& locationInfo,
1172 const std::vector<LogString>& values) const;
1188 void l7dlog(const LevelPtr& level, const std::string& key,
1189 const log4cxx::spi::LocationInfo& locationInfo) const;
1207 void l7dlog(const LevelPtr& level, const std::string& key,
1208 const log4cxx::spi::LocationInfo& locationInfo,
1209 const std::string& val) const;
1228 void l7dlog(const LevelPtr& level, const std::string& key,
1229 const log4cxx::spi::LocationInfo& locationInfo,
1230 const std::string& val1, const std::string& val2) const;
1250 void l7dlog(const LevelPtr& level, const std::string& key,
1251 const log4cxx::spi::LocationInfo& locationInfo,
1252 const std::string& val1, const std::string& val2, const std::string& val3) const;
1253
1254#if LOG4CXX_WCHAR_T_API
1270 void l7dlog(const LevelPtr& level, const std::wstring& key,
1271 const log4cxx::spi::LocationInfo& locationInfo) const;
1289 void l7dlog(const LevelPtr& level, const std::wstring& key,
1290 const log4cxx::spi::LocationInfo& locationInfo,
1291 const std::wstring& val) const;
1310 void l7dlog(const LevelPtr& level, const std::wstring& key,
1311 const log4cxx::spi::LocationInfo& locationInfo,
1312 const std::wstring& val1, const std::wstring& val2) const;
1332 void l7dlog(const LevelPtr& level, const std::wstring& key,
1333 const log4cxx::spi::LocationInfo& locationInfo,
1334 const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
1335#endif
1336#if LOG4CXX_UNICHAR_API
1352 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1353 const log4cxx::spi::LocationInfo& locationInfo) const;
1371 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1372 const log4cxx::spi::LocationInfo& locationInfo,
1373 const std::basic_string<UniChar>& val) const;
1392 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1393 const log4cxx::spi::LocationInfo& locationInfo,
1394 const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
1414 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1415 const log4cxx::spi::LocationInfo& locationInfo,
1416 const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
1417 const std::basic_string<UniChar>& val3) const;
1418#endif
1419#if LOG4CXX_CFSTRING_API
1435 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1436 const log4cxx::spi::LocationInfo& locationInfo) const;
1454 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1455 const log4cxx::spi::LocationInfo& locationInfo,
1456 const CFStringRef& val1) const;
1475 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1476 const log4cxx::spi::LocationInfo& locationInfo,
1477 const CFStringRef& val1, const CFStringRef& val2) const;
1497 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1498 const log4cxx::spi::LocationInfo& locationInfo,
1499 const CFStringRef& val1, const CFStringRef& val2,
1500 const CFStringRef& val3) const;
1501#endif
1502
1511 void log(const LevelPtr& level, const std::string& message,
1512 const log4cxx::spi::LocationInfo& location) const;
1521 void log(const LevelPtr& level, const std::string& message) const;
1522#if LOG4CXX_WCHAR_T_API
1531 void log(const LevelPtr& level, const std::wstring& message,
1532 const log4cxx::spi::LocationInfo& location) const;
1541 void log(const LevelPtr& level, const std::wstring& message) const;
1542#endif
1543#if LOG4CXX_UNICHAR_API
1552 void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
1553 const log4cxx::spi::LocationInfo& location) const;
1562 void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
1563#endif
1564#if LOG4CXX_CFSTRING_API
1573 void log(const LevelPtr& level, const CFStringRef& message,
1574 const log4cxx::spi::LocationInfo& location) const;
1583 void log(const LevelPtr& level, const CFStringRef& message) const;
1584#endif
1593 void logLS(const LevelPtr& level, const LogString& message,
1594 const log4cxx::spi::LocationInfo& location) const;
1595
1596
1597
1603 void removeAllAppenders() override;
1604
1608 void removeAppender(const AppenderPtr appender) override;
1609
1614 void removeAppender(const LogString& name) override;
1615
1619 void setAdditivity(bool additive);
1620
1621 protected:
1622 friend class Hierarchy;
1634 void setParent(LoggerPtr parentLogger);
1639
1640 private:
1641 spi::LoggerRepository* getHierarchy() const;
1642
1643 public:
1650 virtual void setLevel(const LevelPtr level);
1651
1655 void setResourceBundle(const helpers::ResourceBundlePtr& bundle);
1656
1657#if LOG4CXX_WCHAR_T_API
1673 void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
1688 void warn(const std::wstring& msg) const;
1689#endif
1690#if LOG4CXX_UNICHAR_API
1706 void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
1721 void warn(const std::basic_string<UniChar>& msg) const;
1722#endif
1723#if LOG4CXX_CFSTRING_API
1739 void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
1754 void warn(const CFStringRef& msg) const;
1755#endif
1771 void warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
1786 void warn(const std::string& msg) const;
1787
1788#if LOG4CXX_WCHAR_T_API
1804 void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
1819 void trace(const std::wstring& msg) const;
1820#endif
1821#if LOG4CXX_UNICHAR_API
1837 void trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
1852 void trace(const std::basic_string<UniChar>& msg) const;
1853#endif
1854#if LOG4CXX_CFSTRING_API
1870 void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
1885 void trace(const CFStringRef& msg) const;
1886#endif
1902 void trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
1917 void trace(const std::string& msg) const;
1918
1925 void reconfigure( const std::vector<AppenderPtr>& appenders, bool additivity );
1926
1927 private:
1928 //
1929 // prevent copy and assignment
1930 Logger(const Logger&);
1931 Logger& operator=(const Logger&);
1932};
1934}
1935
1940#if !defined(LOG4CXX_UNLIKELY)
1941 #if __GNUC__ >= 3
1948 #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
1949 #else
1956 #define LOG4CXX_UNLIKELY(expr) expr
1957 #endif
1958#endif
1959
1960#if defined(LOG4CXX_ENABLE_STACKTRACE) && !defined(LOG4CXX_STACKTRACE)
1961 #ifndef __has_include
1962 #include <boost/stacktrace.hpp>
1963 #define LOG4CXX_STACKTRACE ::log4cxx::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
1964 #elif __has_include(<stacktrace>)
1965 #include <stacktrace>
1966 #define LOG4CXX_STACKTRACE ::log4cxx::MDC mdc_("stacktrace", LOG4CXX_EOL + std::stacktrace::to_string(std::stacktrace::stacktrace()));
1967 #elif __has_include(<boost/stacktrace.hpp>)
1968 #include <boost/stacktrace.hpp>
1969 #define LOG4CXX_STACKTRACE ::log4cxx::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
1970 #else
1971 #warning "Stacktrace requested but no implementation found"
1972 #endif
1973#endif /* LOG4CXX_ENABLE_STACKTRACE */
1974
1975#if !defined(LOG4CXX_STACKTRACE)
1976#define LOG4CXX_STACKTRACE
1977#endif
1978
1979
1987#define LOG4CXX_LOG(logger, level, message) do { \
1988 if (logger->isEnabledFor(level)) {\
1989 ::log4cxx::helpers::MessageBuffer oss_; \
1990 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1991
1999#define LOG4CXX_LOG_FMT(logger, level, ...) do { \
2000 if (logger->isEnabledFor(level)) {\
2001 logger->forcedLog(level, fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2002
2010#define LOG4CXX_LOGLS(logger, level, message) do { \
2011 if (logger->isEnabledFor(level)) {\
2012 ::log4cxx::helpers::LogCharMessageBuffer oss_; \
2013 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2014
2015#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
2034#define LOG4CXX_DEBUG(logger, message) do { \
2035 if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isDebugEnabledFor(logger))) {\
2036 ::log4cxx::helpers::MessageBuffer oss_; \
2037 logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2038
2045#define LOG4CXX_DEBUG_FMT(logger, ...) do { \
2046 if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isDebugEnabledFor(logger))) {\
2047 logger->forcedLog(::log4cxx::Level::getDebug(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2048#else
2049#define LOG4CXX_DEBUG(logger, message)
2050#define LOG4CXX_DEBUG_FMT(logger, ...)
2051#endif
2052
2053#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000
2066#define LOG4CXX_TRACE(logger, message) do { \
2067 if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isTraceEnabledFor(logger))) {\
2068 ::log4cxx::helpers::MessageBuffer oss_; \
2069 logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2070
2077#define LOG4CXX_TRACE_FMT(logger, ...) do { \
2078 if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isTraceEnabledFor(logger))) {\
2079 logger->forcedLog(::log4cxx::Level::getTrace(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2080#else
2081#define LOG4CXX_TRACE(logger, message)
2082#define LOG4CXX_TRACE_FMT(logger, ...)
2083#endif
2084
2085#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000
2102#define LOG4CXX_INFO(logger, message) do { \
2103 if (::log4cxx::Logger::isInfoEnabledFor(logger)) {\
2104 ::log4cxx::helpers::MessageBuffer oss_; \
2105 logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2106
2113#define LOG4CXX_INFO_FMT(logger, ...) do { \
2114 if (::log4cxx::Logger::isInfoEnabledFor(logger)) {\
2115 logger->forcedLog(::log4cxx::Level::getInfo(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2116#else
2117#define LOG4CXX_INFO(logger, message)
2118#define LOG4CXX_INFO_FMT(logger, ...)
2119#endif
2120
2121#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000
2136#define LOG4CXX_WARN(logger, message) do { \
2137 if (::log4cxx::Logger::isWarnEnabledFor(logger)) {\
2138 ::log4cxx::helpers::MessageBuffer oss_; \
2139 logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2140
2147#define LOG4CXX_WARN_FMT(logger, ...) do { \
2148 if (::log4cxx::Logger::isWarnEnabledFor(logger)) {\
2149 logger->forcedLog(::log4cxx::Level::getWarn(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2150#else
2151#define LOG4CXX_WARN(logger, message)
2152#define LOG4CXX_WARN_FMT(logger, ...)
2153#endif
2154
2155#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000
2170#define LOG4CXX_ERROR(logger, message) do { \
2171 if (::log4cxx::Logger::isErrorEnabledFor(logger)) {\
2172 ::log4cxx::helpers::MessageBuffer oss_; \
2173 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2174
2181#define LOG4CXX_ERROR_FMT(logger, ...) do { \
2182 if (::log4cxx::Logger::isErrorEnabledFor(logger)) {\
2183 logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2184
2192#define LOG4CXX_ASSERT(logger, condition, message) do { \
2193 if (!(condition) && ::log4cxx::Logger::isErrorEnabledFor(logger)) {\
2194 ::log4cxx::helpers::MessageBuffer oss_; \
2195 LOG4CXX_STACKTRACE \
2196 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2197
2205#define LOG4CXX_ASSERT_FMT(logger, condition, ...) do { \
2206 if (!(condition) && ::log4cxx::Logger::isErrorEnabledFor(logger)) {\
2207 LOG4CXX_STACKTRACE \
2208 logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2209
2210#else
2211#define LOG4CXX_ERROR(logger, message)
2212#define LOG4CXX_ERROR_FMT(logger, ...)
2213#define LOG4CXX_ASSERT(logger, condition, message)
2214#define LOG4CXX_ASSERT_FMT(logger, condition, ...)
2215#endif
2216
2217#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000
2229#define LOG4CXX_FATAL(logger, message) do { \
2230 if (::log4cxx::Logger::isFatalEnabledFor(logger)) {\
2231 ::log4cxx::helpers::MessageBuffer oss_; \
2232 logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2233
2240#define LOG4CXX_FATAL_FMT(logger, ...) do { \
2241 if (::log4cxx::Logger::isFatalEnabledFor(logger)) {\
2242 logger->forcedLog(::log4cxx::Level::getFatal(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
2243#else
2244#define LOG4CXX_FATAL(logger, message)
2245#define LOG4CXX_FATAL_FMT(logger, ...)
2246#endif
2247
2255#define LOG4CXX_L7DLOG(logger, level, key) do { \
2256 if (logger->isEnabledFor(level)) {\
2257 logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
2258
2267#define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \
2268 if (logger->isEnabledFor(level)) {\
2269 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
2270
2280#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \
2281 if (logger->isEnabledFor(level)) {\
2282 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
2283
2294#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \
2295 if (logger->isEnabledFor(level)) {\
2296 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
2297
2301
2302#endif //_LOG4CXX_LOGGER_H
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
Definition: hierarchy.h:56
This is the central class in the log4cxx package.
Definition: logger.h:51
void log(const LevelPtr &level, const std::wstring &message) const
Add a new logging event containing message to the appenders attached to this logger if this logger is...
static LoggerPtr getLogger(const std::basic_string< UniChar > &name)
Retrieve a logger by name.
void info(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void setAdditivity(bool additive)
Set the additivity flag for this logger.
virtual const LevelPtr & getEffectiveLevel() const
Starting from this logger, search the logger hierarchy for a non-null level and return it.
void info(const std::wstring &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void removeAllAppenders() override
Remove all previously added appenders from this logger instance.
static LoggerPtr getLogger(const std::string &name, const log4cxx::spi::LoggerFactoryPtr &factory)
Like getLogger except that the type of logger instantiated depends on the type returned by the Logger...
void warn(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo, const std::string &val1, const std::string &val2, const std::string &val3) const
Add a new logging event containing locationInfo and the localized message key using parameters val1,...
void info(const std::basic_string< UniChar > &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
static LoggerPtr getLogger(const std::basic_string< UniChar > &name, const log4cxx::spi::LoggerFactoryPtr &factory)
Like getLogger except that the type of logger instantiated depends on the type returned by the Logger...
void setParent(LoggerPtr parentLogger)
Only the Hierarchy class can set the parent of a logger.
static bool isErrorEnabledFor(const LoggerPtr &logger)
Is logger is enabled for ERROR level logging events?
Definition: logger.h:1095
void callAppenders(const log4cxx::spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p) const
Call the appenders in the hierrachy starting at this.
void log(const LevelPtr &level, const std::basic_string< UniChar > &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void error(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void warn(const std::basic_string< UniChar > &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
static LoggerPtr getLoggerLS(const LogString &name, const log4cxx::spi::LoggerFactoryPtr &factory)
Like getLogger except that the type of logger instantiated depends on the type returned by the Logger...
void debug(const CFStringRef &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for DEBUG ev...
static LoggerPtr getLoggerLS(const LogString &name)
Retrieve a logger by name in Unicode.
void setResourceBundle(const helpers::ResourceBundlePtr &bundle)
Set the resource bundle to be used with localized logging methods.
AppenderList getAllAppenders() const override
Get the appenders contained in this logger as an AppenderList.
Logger(helpers::Pool &pool, const LogString &name)
This constructor initializes a new logger instance and sets its name.
void warn(const std::string &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
void error(const std::wstring &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
void l7dlog(const LevelPtr &level, const std::basic_string< UniChar > &key, const log4cxx::spi::LocationInfo &locationInfo, const std::basic_string< UniChar > &val1, const std::basic_string< UniChar > &val2, const std::basic_string< UniChar > &val3) const
Add a new logging event containing locationInfo and the localized message key using parameters val1,...
void trace(const std::string &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
static LoggerPtr getLogger(const std::wstring &name)
Retrieve a logger by name.
helpers::ResourceBundlePtr getResourceBundle() const
Return the inherited ResourceBundle for this logger.
void fatal(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void logLS(const LevelPtr &level, const LogString &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
static LoggerPtr getLogger(const char *const name)
Retrieve a logger by name in current encoding.
bool isInfoEnabled() const
Is this logger is enabled for INFO level logging events?
void trace(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
log4cxx::spi::LoggerRepository * getLoggerRepository() const
Return the the LoggerRepository where this Logger is attached.
bool isAttached(const AppenderPtr appender) const override
Is appender attached to this logger?
bool isFatalEnabled() const
Is this logger is enabled for FATAL level logging events?
void debug(const std::basic_string< UniChar > &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for DEBUG ev...
void warn(const CFStringRef &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
void log(const LevelPtr &level, const CFStringRef &message) const
Add a new logging event containing message to the appenders attached to this logger if this logger is...
virtual void setLevel(const LevelPtr level)
Set the level of this logger.
void getName(std::wstring &name) const
Put name of this logger into name.
bool isWarnEnabled() const
Is this logger is enabled for WARN level logging events?
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo, const std::wstring &val) const
Add a new logging event containing locationInfo and the localized message key using parameter val to ...
void removeAppender(const LogString &name) override
Remove the appender with the name passed as parameter form the list of appenders.
void debug(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void fatal(const CFStringRef &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
void log(const LevelPtr &level, const std::basic_string< UniChar > &message) const
Add a new logging event containing message to the appenders attached to this logger if this logger is...
void l7dlog(const LevelPtr &level, const std::basic_string< UniChar > &key, const log4cxx::spi::LocationInfo &locationInfo, const std::basic_string< UniChar > &val1, const std::basic_string< UniChar > &val2) const
Add a new logging event containing locationInfo and the localized message key using parameters val1 a...
void log(const LevelPtr &level, const std::string &message) const
Add a new logging event containing message to the appenders attached to this logger if this logger is...
void trace(const std::basic_string< UniChar > &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo) const
Add a new logging event containing locationInfo and the localized message key to attached appender(s)...
void trace(const std::wstring &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void error(const std::string &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo, const CFStringRef &val1, const CFStringRef &val2) const
Add a new logging event containing locationInfo and the localized message key using parameters val1 a...
void fatal(const std::wstring &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
static LoggerPtr getLogger(const CFStringRef &name, const log4cxx::spi::LoggerFactoryPtr &factory)
Like getLogger except that the type of logger instantiated depends on the type returned by the Logger...
const LogString & getName() const
Get the logger name.
LogString getResourceBundleString(const LogString &key) const
Returns the string resource corresponding to key in this logger's inherited resource bundle.
bool isEnabledFor(const LevelPtr &level) const
Is this logger is enabled for logging events at level?
static LoggerPtr getLogger(const wchar_t *const name)
Retrieve a logger by name.
void debug(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void debug(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void info(const std::string &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void forcedLog(const LevelPtr &level, const std::basic_string< UniChar > &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to attached appender(s).
void forcedLog(const LevelPtr &level, const std::basic_string< UniChar > &message) const
Add a new logging event containing message to attached appender(s).
static bool isWarnEnabledFor(const LoggerPtr &logger)
Is logger is enabled for WARN level logging events?
Definition: logger.h:1069
void error(const CFStringRef &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
void error(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void warn(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo, const std::string &val) const
Add a new logging event containing locationInfo and the localized message key using parameter val to ...
void warn(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
void forcedLog(const LevelPtr &level, const CFStringRef &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to attached appender(s).
void forcedLog(const LevelPtr &level, const CFStringRef &message) const
Add a new logging event containing message to attached appender(s).
void fatal(const std::string &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
void log(const LevelPtr &level, const std::wstring &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
static bool isDebugEnabledFor(const LoggerPtr &logger)
Is logger is enabled for DEBUG level logging events?
Definition: logger.h:1009
void warn(const std::wstring &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
AppenderPtr getAppender(const LogString &name) const override
Look for the appender named as name.
void setHierarchy(spi::LoggerRepository *repository)
Only the Hierarchy class can set the hierarchy of a logger.
void debug(const std::wstring &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for DEBUG ev...
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo) const
Add a new logging event containing locationInfo and the localized message key to attached appender(s)...
void trace(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo, const std::string &val1, const std::string &val2) const
Add a new logging event containing locationInfo and the localized message key using parameters val1 a...
static bool isFatalEnabledFor(const LoggerPtr &logger)
Is logger is enabled for FATAL level logging events?
Definition: logger.h:1121
static LoggerPtr getLogger(const CFStringRef &name)
Retrieve a logger by name.
static LoggerPtr getLogger(const std::wstring &name, const log4cxx::spi::LoggerFactoryPtr &factory)
Like getLogger except that the type of logger instantiated depends on the type returned by the Logger...
void error(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void forcedLogLS(const LevelPtr &level, const LogString &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to attached appender(s).
void error(const std::basic_string< UniChar > &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
void l7dlog(const LevelPtr &level, const std::basic_string< UniChar > &key, const log4cxx::spi::LocationInfo &locationInfo, const std::basic_string< UniChar > &val) const
Add a new logging event containing locationInfo and the localized message key using parameter val to ...
void fatal(const std::basic_string< UniChar > &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for ERROR ev...
static bool isInfoEnabledFor(const LoggerPtr &logger)
Is logger is enabled for INFO level logging events?
Definition: logger.h:1043
static LoggerPtr getLogger(const std::string &name)
Retrieve a logger by name in current encoding.
bool isDebugEnabled() const
Is this logger is enabled for DEBUG level logging events?
const LevelPtr & getLevel() const
The assigned Level, if any, for this logger.
void removeHierarchy()
Only the Hierarchy class can remove the hierarchy of a logger.
void error(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void forcedLog(const LevelPtr &level, const std::wstring &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to attached appender(s).
void info(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void getName(std::string &name) const
Put name of this logger into name in current encoding.
void forcedLog(const LevelPtr &level, const std::wstring &message) const
Add a new logging event containing message to attached appender(s).
void l7dlog(const LevelPtr &level, const std::basic_string< UniChar > &key, const log4cxx::spi::LocationInfo &locationInfo) const
Add a new logging event containing locationInfo and the localized message key to attached appender(s)...
void fatal(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void log(const LevelPtr &level, const std::string &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void fatal(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void fatal(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
bool getAdditivity() const
Get the additivity flag for this logger.
void getName(CFStringRef &name) const
Put name of this logger into name.
static LoggerPtr getRootLogger()
Retrieve the root logger.
void trace(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void log(const LevelPtr &level, const CFStringRef &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void warn(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
void trace(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
LoggerPtr getParent() const
The parent of this logger.
void updateThreshold()
Only the Hierarchy class can change the threshold of a logger.
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo, const std::wstring &val1, const std::wstring &val2) const
Add a new logging event containing locationInfo and the localized message key using parameters val1 a...
void l7dlog(const LevelPtr &level, const LogString &key, const log4cxx::spi::LocationInfo &locationInfo, const std::vector< LogString > &values) const
Add a new logging event containing locationInfo and the localized message key using values for parame...
void forcedLog(const LevelPtr &level, const std::string &message, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing message and location to attached appender(s).
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo, const std::wstring &val1, const std::wstring &val2, const std::wstring &val3) const
Add a new logging event containing locationInfo and the localized message key using parameters val1,...
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo) const
Add a new logging event containing locationInfo and the localized message key to attached appender(s)...
void closeNestedAppenders()
Close all attached appenders implementing the AppenderAttachable interface.
void info(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void info(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void info(const CFStringRef &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void debug(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo, const CFStringRef &val1, const CFStringRef &val2, const CFStringRef &val3) const
Add a new logging event containing locationInfo and the localized message key using parameters val1,...
void getName(std::basic_string< UniChar > &name) const
Put name of this logger into name.
void trace(const CFStringRef &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void removeAppender(const AppenderPtr appender) override
Remove the appender passed as parameter form the list of appenders.
static bool isTraceEnabledFor(const LoggerPtr &logger)
Is logger is enabled for TRACE level logging events?
Definition: logger.h:1147
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo, const CFStringRef &val1) const
Add a new logging event containing locationInfo and the localized message key using parameter val to ...
void debug(const std::string &msg) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for DEBUG ev...
void reconfigure(const std::vector< AppenderPtr > &appenders, bool additivity)
Reconfigure this logger by configuring all of the appenders.
bool isErrorEnabled() const
Is this logger is enabled for ERROR level logging events?
void addAppender(const AppenderPtr newAppender) override
Add newAppender to the list of appenders of this Logger instance.
void forcedLog(const LevelPtr &level, const std::string &message) const
Add a new logging event containing message to attached appender(s).
bool isTraceEnabled() const
Is this logger is enabled for TRACE level logging events?
Definition: pool.h:33
This Interface is for attaching Appenders to objects.
Definition: appenderattachable.h:34
This class represents the location of a logging statement.
Definition: locationinfo.h:46
Implement this interface to create new instances of Logger or a sub-class of Logger.
Definition: loggerfactory.h:33
A LoggerRepository is used to create and retrieve Loggers.
Definition: loggerrepository.h:43
const struct __CFString * CFStringRef
Definition: logstring.h:30
LOG4CXX_PTR_DEF(LoggerRepository)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:32
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:34
Definition: configuration.h:25
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr)
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:28
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:29
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:27
std::vector< LoggerPtr > LoggerList
Definition: logmanager.h:29
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:38
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145