Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
log4cxx/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_NS
29{
30
31namespace spi
32{
33class LoggingEvent;
37class LoggerFactory;
39}
40
41class Logger;
44
45
50class LOG4CXX_EXPORT Logger
51 : public virtual spi::AppenderAttachable
52{
53 public:
59
60 private:
61 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(LoggerPrivate, m_priv)
62 int m_threshold;
63
64 public:
71 Logger(const LogString& name);
73
74
82 void addAppender(const AppenderPtr& newAppender) override;
83
84
90 void callAppenders(const spi::LoggingEventPtr& event) const;
91
97
111 void debug(const std::string& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
112#if LOG4CXX_WCHAR_T_API
128 void debug(const std::wstring& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
129#endif
130#if LOG4CXX_CFSTRING_API
147#endif
148
164 void error(const std::string& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
165#if LOG4CXX_WCHAR_T_API
181 void error(const std::wstring& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
182#endif
183#if LOG4CXX_CFSTRING_API
200#endif
201
217 void fatal(const std::string& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
218#if LOG4CXX_WCHAR_T_API
234 void fatal(const std::wstring& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
235#endif
236#if LOG4CXX_CFSTRING_API
253#endif
254
262 void addEvent(const LevelPtr& level, std::string&& message
264
272 void addEvent(const LevelPtr& level, helpers::AsyncBuffer&& messageAppender
274
281 void addFatalEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
282
290
297 void addErrorEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
298
306
313 void addWarnEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
314
322
329 void addInfoEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
330
338
345 void addDebugEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
346
354
361 void addTraceEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
362
370
378 void forcedLog(const LevelPtr& level, const std::string& message,
380
381#if LOG4CXX_WCHAR_T_API
389 void addEvent(const LevelPtr& level, std::wstring&& message
391
398 void addFatalEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
399
406 void addErrorEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
407
414 void addWarnEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
415
422 void addInfoEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
423
430 void addDebugEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
431
438 void addTraceEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
439
447 void forcedLog(const LevelPtr& level, const std::wstring& message,
449#endif
450#if LOG4CXX_CFSTRING_API
458 void forcedLog(const LevelPtr& level, const CFStringRef& message,
460#endif
468 void addEventLS(const LevelPtr& level, LogString&& message
470
478 void forcedLogLS(const LevelPtr& level, const LogString& message,
480
484 bool getAdditivity() const;
485
491 AppenderList getAllAppenders() const override;
492
497 AppenderPtr getAppender(const LogString& name) const override;
498
509
510
515 const LogString& getName() const;
516
521 void getName(std::string& name) const;
522#if LOG4CXX_WCHAR_T_API
527 void getName(std::wstring& name) const;
528#endif
529#if LOG4CXX_CFSTRING_API
534 void getName(CFStringRef& name) const;
535#endif
536
544
545
552
557
562 static LoggerPtr getLogger(const std::string& name);
563#if LOG4CXX_WCHAR_T_API
568 static LoggerPtr getLogger(const std::wstring& name);
569#endif
570#if LOG4CXX_CFSTRING_API
575 static LoggerPtr getLogger(const CFStringRef& name);
576#endif
581
595 static LoggerPtr getLoggerLS(const LogString& name,
596 const spi::LoggerFactoryPtr& factory = {});
597
607 helpers::ResourceBundlePtr getResourceBundle() const;
608
609 protected:
620
621 public:
637 void info(const std::string& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
638#if LOG4CXX_WCHAR_T_API
654 void info(const std::wstring& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
655#endif
656#if LOG4CXX_CFSTRING_API
673#endif
674
678 bool isAttached(const AppenderPtr& appender) const override;
679
714 bool isDebugEnabled() const;
715
737 inline static bool isDebugEnabledFor(const LoggerPtr& logger)
738 {
739 return logger && logger->m_threshold <= Level::DEBUG_INT && logger->isDebugEnabled();
740 }
741
747 bool isEnabledFor(const LevelPtr& level) const;
748
749
759 bool isInfoEnabled() const;
760
771 inline static bool isInfoEnabledFor(const LoggerPtr& logger)
772 {
773 return logger && logger->m_threshold <= Level::INFO_INT && logger->isInfoEnabled();
774 }
775
785 bool isWarnEnabled() const;
786
797 inline static bool isWarnEnabledFor(const LoggerPtr& logger)
798 {
799 return logger && logger->m_threshold <= Level::WARN_INT && logger->isWarnEnabled();
800 }
801
811 bool isErrorEnabled() const;
812
823 inline static bool isErrorEnabledFor(const LoggerPtr& logger)
824 {
825 return logger && logger->m_threshold <= Level::ERROR_INT && logger->isErrorEnabled();
826 }
827
837 bool isFatalEnabled() const;
838
849 inline static bool isFatalEnabledFor(const LoggerPtr& logger)
850 {
851 return logger && logger->m_threshold <= Level::FATAL_INT && logger->isFatalEnabled();
852 }
853
863 bool isTraceEnabled() const;
864
875 inline static bool isTraceEnabledFor(const LoggerPtr& logger)
876 {
877 return logger && logger->m_threshold <= Level::TRACE_INT && logger->isTraceEnabled();
878 }
879
899 void l7dlog(const LevelPtr& level, const LogString& key,
900 const LOG4CXX_NS::spi::LocationInfo& locationInfo,
901 const std::vector<LogString>& values) const;
902
924 void l7dlog(const LevelPtr& level, const std::string& key,
926 const std::string& val1 = {}, const std::string& val2 = {}, const std::string& val3 = {}) const;
927
928#if LOG4CXX_WCHAR_T_API
948 void l7dlog(const LevelPtr& level, const std::wstring& key,
950 const std::wstring& val1 = {}, const std::wstring& val2 = {}, const std::wstring& val3 = {}) const;
951#endif
952#if LOG4CXX_CFSTRING_API
972 void l7dlog(const LevelPtr& level, const CFStringRef& key,
974 const CFStringRef& val1 = {}, const CFStringRef& val2 = {}, const CFStringRef& val3 = {}) const;
975#endif
976
985 void log(const LevelPtr& level, const std::string& message,
987#if LOG4CXX_WCHAR_T_API
996 void log(const LevelPtr& level, const std::wstring& message,
998#endif
999#if LOG4CXX_CFSTRING_API
1008 void log(const LevelPtr& level, const CFStringRef& message,
1010#endif
1019 void logLS(const LevelPtr& level, const LogString& message,
1021
1027 void removeAllAppenders() override;
1028
1033 bool removeAppender(const AppenderPtr& appender) override;
1034
1039 bool removeAppender(const LogString& name) override;
1040
1045 bool replaceAppender(const AppenderPtr& oldAppender, const AppenderPtr& newAppender) override;
1046
1050 void replaceAppenders(const AppenderList& newList) override;
1051
1055 void setAdditivity(bool additive);
1056
1057 protected:
1058 friend class Hierarchy;
1059
1071 void setParent(const LoggerPtr& parentLogger);
1076
1077 public: // Unit testing support methods
1078 void changeParentTo(const LoggerPtr& otherLogger);
1079
1082 bool isThresholdEqualTo(const LevelPtr& level) const;
1083
1086 bool isThresholdEqualTo(const LoggerPtr& other) const;
1087
1090 bool isThresholdValid() const;
1091
1092 private:
1093 spi::LoggerRepository* getHierarchy() const;
1094
1095 public:
1102 virtual void setLevel(const LevelPtr& level);
1103
1107 void setResourceBundle(const helpers::ResourceBundlePtr& bundle);
1108
1109#if LOG4CXX_WCHAR_T_API
1125 void warn(const std::wstring& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
1126#endif
1127#if LOG4CXX_CFSTRING_API
1144#endif
1160 void warn(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
1161
1162#if LOG4CXX_WCHAR_T_API
1178 void trace(const std::wstring& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
1179#endif
1180#if LOG4CXX_CFSTRING_API
1197#endif
1213 void trace(const std::string& msg, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
1214
1222 void reconfigure( const AppenderList& newList, bool newAdditivity );
1223
1224 private:
1225 //
1226 // prevent copy and assignment
1227 Logger(const Logger&);
1228 Logger& operator=(const Logger&);
1229};
1230LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
1231}
1232
1233#if !defined(LOG4CXX_UNLIKELY)
1234 #if __GNUC__ >= 3
1241 #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
1242 #else
1249 #define LOG4CXX_UNLIKELY(expr) expr
1250 #endif
1251#endif
1252
1253#if defined(LOG4CXX_ENABLE_STACKTRACE) && !defined(LOG4CXX_STACKTRACE)
1254 #ifndef __has_include
1255 #include <boost/stacktrace.hpp>
1256 #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
1257 #elif __has_include(<stacktrace>)
1258 #include <stacktrace>
1259 #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + std::stacktrace::to_string(std::stacktrace::stacktrace()));
1260 #elif __has_include(<boost/stacktrace.hpp>)
1261 #include <boost/stacktrace.hpp>
1262 #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
1263 #else
1264 #warning "Stacktrace requested but no implementation found"
1265 #endif
1266#endif /* LOG4CXX_ENABLE_STACKTRACE */
1267
1268#if !defined(LOG4CXX_STACKTRACE)
1269#define LOG4CXX_STACKTRACE
1270#endif
1271
1272#ifndef LOG4CXX_FMT_VA_ARG
1273 #define LOG4CXX_FMT_VA_ARG(...) , __VA_ARGS__
1274#endif
1275
1279
1287#define LOG4CXX_LOG(logger, level, message) do { \
1288 if (logger->isEnabledFor(level)) {\
1289 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1290 logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1291
1300#define LOG4CXX_LOG_FMT(logger, level, fmt, ...) do { \
1301 if (logger->isEnabledFor(level)) {\
1302 logger->addEvent(level, ::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__) ), LOG4CXX_LOCATION); }} while (0)
1303
1311#define LOG4CXX_LOGLS(logger, level, message) do { \
1312 if (logger->isEnabledFor(level)) {\
1313 ::LOG4CXX_NS::helpers::LogCharMessageBuffer oss_; \
1314 logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1315
1316#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
1336#define LOG4CXX_DEBUG(logger, message) do { \
1337 if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isDebugEnabledFor(logger))) {\
1338 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1339 logger->addDebugEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1340
1360#define LOG4CXX_DEBUG_FMT(logger, fmt, ...) do { \
1361 if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isDebugEnabledFor(logger))) {\
1362 logger->addDebugEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__) ), LOG4CXX_LOCATION); }} while (0)
1363#else
1364#define LOG4CXX_DEBUG(logger, message)
1365#define LOG4CXX_DEBUG_FMT(logger, fmt, ...)
1366#endif
1367
1368#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000
1380#define LOG4CXX_TRACE(logger, message) do { \
1381 if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isTraceEnabledFor(logger))) {\
1382 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1383 logger->addTraceEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1384
1397#define LOG4CXX_TRACE_FMT(logger, fmt, ...) do { \
1398 if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isTraceEnabledFor(logger))) {\
1399 logger->addTraceEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
1400#else
1401#define LOG4CXX_TRACE(logger, message)
1402#define LOG4CXX_TRACE_FMT(logger, fmt, ...)
1403#endif
1404
1405#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000
1422#define LOG4CXX_INFO(logger, message) do { \
1423 if (::LOG4CXX_NS::Logger::isInfoEnabledFor(logger)) {\
1424 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1425 logger->addInfoEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1426
1443#define LOG4CXX_INFO_FMT(logger, fmt, ...) do { \
1444 if (::LOG4CXX_NS::Logger::isInfoEnabledFor(logger)) {\
1445 logger->addInfoEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
1446#else
1447#define LOG4CXX_INFO(logger, message)
1448#define LOG4CXX_INFO_FMT(logger, fmt, ...)
1449#endif
1450
1451#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000
1466#define LOG4CXX_WARN(logger, message) do { \
1467 if (::LOG4CXX_NS::Logger::isWarnEnabledFor(logger)) {\
1468 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1469 logger->addWarnEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1470
1486#define LOG4CXX_WARN_FMT(logger, fmt, ...) do { \
1487 if (::LOG4CXX_NS::Logger::isWarnEnabledFor(logger)) {\
1488 logger->addWarnEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
1489#else
1490#define LOG4CXX_WARN(logger, message)
1491#define LOG4CXX_WARN_FMT(logger, fmt, ...)
1492#endif
1493
1494#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000
1509#define LOG4CXX_ERROR(logger, message) do { \
1510 if (::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
1511 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1512 logger->addErrorEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1513
1529#define LOG4CXX_ERROR_FMT(logger, fmt, ...) do { \
1530 if (::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
1531 logger->addErrorEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
1532
1540#define LOG4CXX_ASSERT(logger, condition, message) do { \
1541 if (!(condition) && ::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
1542 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1543 LOG4CXX_STACKTRACE \
1544 logger->addErrorEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1545
1556#define LOG4CXX_ASSERT_FMT(logger, condition, fmt, ...) do { \
1557 if (!(condition) && ::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
1558 LOG4CXX_STACKTRACE \
1559 logger->addErrorEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
1560
1561#else
1562#define LOG4CXX_ERROR(logger, message)
1563#define LOG4CXX_ERROR_FMT(logger, fmt, ...)
1564#define LOG4CXX_ASSERT(logger, condition, message)
1565#define LOG4CXX_ASSERT_FMT(logger, condition, fmt, ...)
1566#endif
1567
1568#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000
1580#define LOG4CXX_FATAL(logger, message) do { \
1581 if (::LOG4CXX_NS::Logger::isFatalEnabledFor(logger)) {\
1582 ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
1583 logger->addFatalEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1584
1597#define LOG4CXX_FATAL_FMT(logger, fmt, ...) do { \
1598 if (::LOG4CXX_NS::Logger::isFatalEnabledFor(logger)) {\
1599 logger->addFatalEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
1600#else
1601#define LOG4CXX_FATAL(logger, message)
1602#define LOG4CXX_FATAL_FMT(logger, fmt, ...)
1603#endif
1604
1612#define LOG4CXX_L7DLOG(logger, level, key) do { \
1613 if (logger->isEnabledFor(level)) {\
1614 logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
1615
1624#define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \
1625 if (logger->isEnabledFor(level)) {\
1626 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
1627
1637#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \
1638 if (logger->isEnabledFor(level)) {\
1639 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
1640
1651#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \
1652 if (logger->isEnabledFor(level)) {\
1653 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
1654
1656
1657#endif //_LOG4CXX_LOGGER_H
@ DEBUG_INT
Definition level.h:192
@ WARN_INT
Definition level.h:190
@ INFO_INT
Definition level.h:191
@ ERROR_INT
Definition level.h:189
@ FATAL_INT
Definition level.h:188
@ TRACE_INT
Definition level.h:193
This is the central class in the log4cxx package.
Definition log4cxx/logger.h:52
void trace(const CFStringRef &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void setAdditivity(bool additive)
Set the additivity flag for this logger.
void forcedLog(const LevelPtr &level, const std::string &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
void addWarnEvent(std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new warning level logging event containing message and location to attached appender(s) without...
void addDebugEvent(std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new debug level logging event containing message and location to attached appender(s) without f...
void removeAllAppenders() override
Remove all previously added appenders from this logger instance.
bool removeAppender(const AppenderPtr &appender) override
Remove appender from the list of appenders.
friend class Hierarchy
Definition log4cxx/logger.h:1058
static bool isErrorEnabledFor(const LoggerPtr &logger)
Is logger is enabled for ERROR level logging events?
Definition log4cxx/logger.h:823
void addDebugEvent(helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new DEBUG level LoggingEvent which was requested at sourceLocation wher...
void warn(const CFStringRef &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
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.
void fatal(const std::wstring &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void addEvent(const LevelPtr &level, std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
void forcedLogLS(const LevelPtr &level, const LogString &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
void callAppenders(const spi::LoggingEventPtr &event) const
Send event to all appenders attached to this or attached to a parent of this.
void addWarnEvent(std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new warning level logging event containing message and location to attached appender(s) without...
void forcedLog(const LevelPtr &level, const std::wstring &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
static LoggerPtr getLogger(const std::wstring &name)
Retrieve a logger by name.
helpers::ResourceBundlePtr getResourceBundle() const
Return the inherited ResourceBundle for this logger.
bool isThresholdEqualTo(const LoggerPtr &other) const
Is m_threshold the same as other.
bool isInfoEnabled() const
Is this logger is enabled for INFO level logging events?
void error(const std::string &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void addInfoEvent(std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new info level logging event containing message and location to attached appender(s) without fu...
void replaceAppenders(const AppenderList &newList) override
Replace all previously added appenders with newList.
bool isFatalEnabled() const
Is this logger is enabled for FATAL level logging events?
void error(const std::wstring &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) 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 spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void getName(std::wstring &name) const
Put name of this logger into name.
void addTraceEvent(std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new trace level logging event containing message and location to attached appender(s) without f...
void l7dlog(const LevelPtr &level, const std::string &key, const spi::LocationInfo &locationInfo=spi::LocationInfo::getLocationUnavailable(), 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,...
bool isWarnEnabled() const
Is this logger is enabled for WARN level logging events?
void addEventLS(const LevelPtr &level, LogString &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
void warn(const std::string &msg, const log4cxx::spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
bool removeAppender(const LogString &name) override
Remove the name appender from the list of appenders.
void trace(const std::string &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void addAppender(const AppenderPtr &newAppender) override
Add newAppender to the list of appenders of this Logger instance.
void debug(const std::string &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
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?
void addFatalEvent(std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new fatal level logging event containing message and location to attached appender(s) without f...
void info(const std::wstring &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
void error(const CFStringRef &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void updateCachedConfiguration()
Recalculate the effective configuration.
static bool isWarnEnabledFor(const LoggerPtr &logger)
Is logger is enabled for WARN level logging events?
Definition log4cxx/logger.h:797
bool isThresholdEqualTo(const LevelPtr &level) const
Is m_threshold the same as level->toInt().
void l7dlog(const LevelPtr &level, const CFStringRef &key, const spi::LocationInfo &locationInfo=spi::LocationInfo::getLocationUnavailable(), 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,...
virtual LevelPtr getEffectiveLevel() const
Starting from this logger, search the logger hierarchy for a non-null level and return it.
void fatal(const CFStringRef &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) 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 spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void addEvent(const LevelPtr &level, std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
void addFatalEvent(helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new FATAL level LoggingEvent which was requested at sourceLocation wher...
void log(const LevelPtr &level, const CFStringRef &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void addErrorEvent(std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new error level logging event containing message and location to attached appender(s) without f...
void info(const CFStringRef &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for INFO eve...
static bool isDebugEnabledFor(const LoggerPtr &logger)
Is logger is enabled for DEBUG level logging events?
Definition log4cxx/logger.h:737
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 setParent(const LoggerPtr &parentLogger)
Only the Hierarchy class can set the parent of a logger.
void l7dlog(const LevelPtr &level, const std::wstring &key, const spi::LocationInfo &locationInfo=spi::LocationInfo::getLocationUnavailable(), 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,...
static bool isFatalEnabledFor(const LoggerPtr &logger)
Is logger is enabled for FATAL level logging events?
Definition log4cxx/logger.h:849
static LoggerPtr getLogger(const CFStringRef &name)
Retrieve a logger by name.
void addInfoEvent(helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new INFO level LoggingEvent which was requested at sourceLocation where...
void debug(const CFStringRef &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void debug(const std::wstring &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
Logger(const LogString &name)
This constructor initializes a new logger instance and sets its name.
void changeParentTo(const LoggerPtr &otherLogger)
void addFatalEvent(std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new fatal level logging event containing message and location to attached appender(s) without f...
static bool isInfoEnabledFor(const LoggerPtr &logger)
Is logger is enabled for INFO level logging events?
Definition log4cxx/logger.h:771
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?
void removeHierarchy()
Only the Hierarchy class can remove the hierarchy of a logger.
void getName(std::string &name) const
Put name of this logger into name in current encoding.
void addErrorEvent(helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new ERROR level LoggingEvent which was requested at sourceLocation wher...
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 fatal(const std::string &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg and location to attached appender(s) if this logger is enabled...
void addTraceEvent(helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new TRACE level LoggingEvent which was requested at sourceLocation wher...
LoggerPtr getParent() const
The parent of this logger.
void l7dlog(const LevelPtr &level, const LogString &key, const log4cxx::spi::LocationInfo &locationInfo, const std::vector< LogString > &values) const
bool isAttached(const AppenderPtr &appender) const override
Is appender attached to this logger?
void closeNestedAppenders()
Close all attached appenders implementing the AppenderAttachable interface.
void addErrorEvent(std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new error level logging event containing message and location to attached appender(s) without f...
void reconfigure(const AppenderList &newList, bool newAdditivity)
Replace all current appenders with newList and set the additivity flag to newAdditivity.
void logLS(const LevelPtr &level, const LogString &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void log(const LevelPtr &level, const std::wstring &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to the appenders attached to this logger if t...
void addWarnEvent(helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new WARN level LoggingEvent which was requested at sourceLocation where...
LevelPtr getLevel() const
The assigned Level, if any, for this logger.
void forcedLog(const LevelPtr &level, const CFStringRef &message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing message and location to attached appender(s) without further check...
bool replaceAppender(const AppenderPtr &oldAppender, const AppenderPtr &newAppender) override
Replace oldAppender with newAppender.
static LoggerPtr getLoggerLS(const LogString &name, const spi::LoggerFactoryPtr &factory={})
Like getLogger except that the type of logger instantiated depends on the type returned by the Logger...
void addInfoEvent(std::wstring &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new info level logging event containing message and location to attached appender(s) without fu...
void addDebugEvent(std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new debug level logging event containing message and location to attached appender(s) without f...
bool isThresholdValid() const
Is m_threshold the same as getEffectiveLevel()->toInt().
static bool isTraceEnabledFor(const LoggerPtr &logger)
Is logger is enabled for TRACE level logging events?
Definition log4cxx/logger.h:875
static spi::LoggerRepositoryPtr getLoggerRepository()
The object that holds all Logger instances.
void addEvent(const LevelPtr &level, helpers::AsyncBuffer &&messageAppender, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add to attached appender(s) a new level LoggingEvent which was requested at sourceLocation where the ...
bool isErrorEnabled() const
Is this logger is enabled for ERROR level logging events?
void trace(const std::wstring &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for TRACE ev...
void warn(const std::wstring &msg, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new logging event containing msg to attached appender(s) if this logger is enabled for WARN eve...
virtual void setLevel(const LevelPtr &level)
Set the level of this logger.
void addTraceEvent(std::string &&message, const spi::LocationInfo &location=spi::LocationInfo::getLocationUnavailable()) const
Add a new trace level logging event containing message and location to attached appender(s) without f...
bool isTraceEnabled() const
Is this logger is enabled for TRACE level logging events?
This class is used by the LOG4CXX_INFO_ASYNC and similar macros to support insertion operators.
Definition asyncbuffer.h:56
This Interface is for attaching Appenders to objects.
Definition appenderattachable.h:37
This class represents the location of a logging statement.
Definition locationinfo.h:40
static const LocationInfo & getLocationUnavailable()
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
The data recorded for each logging request.
Definition loggingevent.h:47
const struct __CFString * CFStringRef
Definition logstring.h:30
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition repositoryselector.h:28
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition appender.h:32
LOG4CXX_PTR_DEF(LoggingEvent)
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr)
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Appender > AppenderPtr
Definition basicconfigurator.h:29
std::shared_ptr< Level > LevelPtr
Definition optionconverter.h:28
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Logger > LoggerPtr
Definition provisionnode.h:28
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141