Apache log4cxx Version 0.13.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
21#if defined(_MSC_VER) && (_MSC_VER < 1900)
22 #pragma warning ( push )
23 #pragma warning ( disable: 4127 )
24#endif
25#if defined(_MSC_VER)
26 #pragma warning ( push )
27 #pragma warning ( disable: 4231 4251 4275 4786 )
28#endif
29
31#include <log4cxx/level.h>
36
37namespace log4cxx
38{
39
40namespace helpers
41{
42class synchronized;
43}
44
45namespace spi
46{
47class LoggerRepository;
49class LoggerFactory;
51}
52
53class Logger;
57
58
63class LOG4CXX_EXPORT Logger :
65 public virtual helpers::Object
66{
67 public:
73
74 private:
78 helpers::Pool* pool;
79
80 protected:
85
91
96
101 helpers::ResourceBundlePtr resourceBundle;
102
103
104 // Loggers need to know what Hierarchy they are in
106
107 helpers::AppenderAttachableImplPtr aai;
108
117
118 protected:
120
132
133 public:
135
136
144 virtual void addAppender(const AppenderPtr newAppender);
145
146
160
166
180 void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
193 void debug(const std::string& msg) const;
194#if LOG4CXX_WCHAR_T_API
208 void debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
221 void debug(const std::wstring& msg) const;
222#endif
223#if LOG4CXX_UNICHAR_API
237 void debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
250 void debug(const std::basic_string<UniChar>& msg) const;
251#endif
252#if LOG4CXX_CFSTRING_API
266 void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
279 void debug(const CFStringRef& msg) const;
280#endif
281
295 void error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
308 void error(const std::string& msg) const;
309#if LOG4CXX_WCHAR_T_API
322 void error(const std::wstring& msg) const;
336 void error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
337#endif
338#if LOG4CXX_UNICHAR_API
352 void error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
365 void error(const std::basic_string<UniChar>& msg) const;
366#endif
367#if LOG4CXX_CFSTRING_API
381 void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
394 void error(const CFStringRef& msg) const;
395#endif
396
410 void fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
423 void fatal(const std::string& msg) const;
424#if LOG4CXX_WCHAR_T_API
438 void fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
451 void fatal(const std::wstring& msg) const;
452#endif
453#if LOG4CXX_UNICHAR_API
467 void fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
480 void fatal(const std::basic_string<UniChar>& msg) const;
481#endif
482#if LOG4CXX_CFSTRING_API
496 void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
509 void fatal(const CFStringRef& msg) const;
510#endif
511
519 void forcedLog(const LevelPtr& level, const std::string& message,
520 const log4cxx::spi::LocationInfo& location) const;
527 void forcedLog(const LevelPtr& level, const std::string& message) const;
528
529#if LOG4CXX_WCHAR_T_API
537 void forcedLog(const LevelPtr& level, const std::wstring& message,
538 const log4cxx::spi::LocationInfo& location) const;
545 void forcedLog(const LevelPtr& level, const std::wstring& message) const;
546#endif
547#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
555 void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
556 const log4cxx::spi::LocationInfo& location) const;
563 void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
564#endif
565#if LOG4CXX_CFSTRING_API
573 void forcedLog(const LevelPtr& level, const CFStringRef& message,
574 const log4cxx::spi::LocationInfo& location) const;
581 void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
582#endif
590 void forcedLogLS(const LevelPtr& level, const LogString& message,
591 const log4cxx::spi::LocationInfo& location) const;
592
596 bool getAdditivity() const;
597
603 AppenderList getAllAppenders() const;
604
610
620 virtual const LevelPtr& getEffectiveLevel() const;
621
627
628
633 const LogString& getName() const
634 {
635 return name;
636 }
641 void getName(std::string& name) const;
642#if LOG4CXX_WCHAR_T_API
647 void getName(std::wstring& name) const;
648#endif
649#if LOG4CXX_UNICHAR_API
654 void getName(std::basic_string<UniChar>& name) const;
655#endif
656#if LOG4CXX_CFSTRING_API
661 void getName(CFStringRef& name) const;
662#endif
663
671
672
679
684 static LoggerPtr getLogger(const std::string& name);
689 static LoggerPtr getLogger(const char* const name);
690#if LOG4CXX_WCHAR_T_API
695 static LoggerPtr getLogger(const std::wstring& name);
700 static LoggerPtr getLogger(const wchar_t* const name);
701#endif
702#if LOG4CXX_UNICHAR_API
707 static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
708#endif
709#if LOG4CXX_CFSTRING_API
714 static LoggerPtr getLogger(const CFStringRef& name);
715#endif
720 static LoggerPtr getLoggerLS(const LogString& name);
721
726
740 static LoggerPtr getLoggerLS(const LogString& name,
741 const log4cxx::spi::LoggerFactoryPtr& factory);
755 static LoggerPtr getLogger(const std::string& name,
756 const log4cxx::spi::LoggerFactoryPtr& factory);
757#if LOG4CXX_WCHAR_T_API
771 static LoggerPtr getLogger(const std::wstring& name,
772 const log4cxx::spi::LoggerFactoryPtr& factory);
773#endif
774#if LOG4CXX_UNICHAR_API
788 static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
789 const log4cxx::spi::LoggerFactoryPtr& factory);
790#endif
791#if LOG4CXX_CFSTRING_API
805 static LoggerPtr getLogger(const CFStringRef& name,
806 const log4cxx::spi::LoggerFactoryPtr& factory);
807#endif
808
818 helpers::ResourceBundlePtr getResourceBundle() const;
819
820 protected:
831
832 public:
846 void info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
847 void info(const std::string& msg) const;
848#if LOG4CXX_WCHAR_T_API
862 void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
875 void info(const std::wstring& msg) const;
876#endif
877#if LOG4CXX_UNICHAR_API
891 void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
904 void info(const std::basic_string<UniChar>& msg) const;
905#endif
906#if LOG4CXX_CFSTRING_API
920 void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
933 void info(const CFStringRef& msg) const;
934#endif
935
939 bool isAttached(const AppenderPtr appender) const;
940
975 bool isDebugEnabled() const;
976
985 bool isEnabledFor(const LevelPtr& level) const;
986
987
995 bool isInfoEnabled() const;
996
1004 bool isWarnEnabled() const;
1005
1013 bool isErrorEnabled() const;
1014
1022 bool isFatalEnabled() const;
1023
1031 bool isTraceEnabled() const;
1032
1049 void l7dlog(const LevelPtr& level, const LogString& key,
1050 const log4cxx::spi::LocationInfo& locationInfo,
1051 const std::vector<LogString>& values) const;
1066 void l7dlog(const LevelPtr& level, const std::string& key,
1067 const log4cxx::spi::LocationInfo& locationInfo) const;
1083 void l7dlog(const LevelPtr& level, const std::string& key,
1084 const log4cxx::spi::LocationInfo& locationInfo,
1085 const std::string& val1) const;
1102 void l7dlog(const LevelPtr& level, const std::string& key,
1103 const log4cxx::spi::LocationInfo& locationInfo,
1104 const std::string& val1, const std::string& val2) const;
1122 void l7dlog(const LevelPtr& level, const std::string& key,
1123 const log4cxx::spi::LocationInfo& locationInfo,
1124 const std::string& val1, const std::string& val2, const std::string& val3) const;
1125
1126#if LOG4CXX_WCHAR_T_API
1141 void l7dlog(const LevelPtr& level, const std::wstring& key,
1142 const log4cxx::spi::LocationInfo& locationInfo) const;
1158 void l7dlog(const LevelPtr& level, const std::wstring& key,
1159 const log4cxx::spi::LocationInfo& locationInfo,
1160 const std::wstring& val1) const;
1177 void l7dlog(const LevelPtr& level, const std::wstring& key,
1178 const log4cxx::spi::LocationInfo& locationInfo,
1179 const std::wstring& val1, const std::wstring& val2) const;
1197 void l7dlog(const LevelPtr& level, const std::wstring& key,
1198 const log4cxx::spi::LocationInfo& locationInfo,
1199 const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
1200#endif
1201#if LOG4CXX_UNICHAR_API
1216 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1217 const log4cxx::spi::LocationInfo& locationInfo) const;
1233 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1234 const log4cxx::spi::LocationInfo& locationInfo,
1235 const std::basic_string<UniChar>& val1) const;
1252 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1253 const log4cxx::spi::LocationInfo& locationInfo,
1254 const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
1272 void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1273 const log4cxx::spi::LocationInfo& locationInfo,
1274 const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
1275 const std::basic_string<UniChar>& val3) const;
1276#endif
1277#if LOG4CXX_CFSTRING_API
1292 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1293 const log4cxx::spi::LocationInfo& locationInfo) const;
1309 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1310 const log4cxx::spi::LocationInfo& locationInfo,
1311 const CFStringRef& val1) const;
1328 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1329 const log4cxx::spi::LocationInfo& locationInfo,
1330 const CFStringRef& val1, const CFStringRef& val2) const;
1348 void l7dlog(const LevelPtr& level, const CFStringRef& key,
1349 const log4cxx::spi::LocationInfo& locationInfo,
1350 const CFStringRef& val1, const CFStringRef& val2,
1351 const CFStringRef& val3) const;
1352#endif
1353
1361 void log(const LevelPtr& level, const std::string& message,
1362 const log4cxx::spi::LocationInfo& location) const;
1370 void log(const LevelPtr& level, const std::string& message) const;
1371#if LOG4CXX_WCHAR_T_API
1379 void log(const LevelPtr& level, const std::wstring& message,
1380 const log4cxx::spi::LocationInfo& location) const;
1388 void log(const LevelPtr& level, const std::wstring& message) const;
1389#endif
1390#if LOG4CXX_UNICHAR_API
1398 void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
1399 const log4cxx::spi::LocationInfo& location) const;
1407 void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
1408#endif
1409#if LOG4CXX_CFSTRING_API
1417 void log(const LevelPtr& level, const CFStringRef& message,
1418 const log4cxx::spi::LocationInfo& location) const;
1426 void log(const LevelPtr& level, const CFStringRef& message) const;
1427#endif
1435 void logLS(const LevelPtr& level, const LogString& message,
1436 const log4cxx::spi::LocationInfo& location) const;
1437
1438
1439
1446
1450 void removeAppender(const AppenderPtr appender);
1451
1456 void removeAppender(const LogString& name);
1457
1461 void setAdditivity(bool additive);
1462
1463 protected:
1464 friend class Hierarchy;
1468
1469 public:
1476 virtual void setLevel(const LevelPtr level);
1477
1481 inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
1482 {
1483 resourceBundle = bundle;
1484 }
1485
1486#if LOG4CXX_WCHAR_T_API
1500 void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
1513 void warn(const std::wstring& msg) const;
1514#endif
1515#if LOG4CXX_UNICHAR_API
1529 void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
1542 void warn(const std::basic_string<UniChar>& msg) const;
1543#endif
1544#if LOG4CXX_CFSTRING_API
1558 void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
1571 void warn(const CFStringRef& msg) const;
1572#endif
1586 void warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
1599 void warn(const std::string& msg) const;
1600
1601#if LOG4CXX_WCHAR_T_API
1615 void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
1628 void trace(const std::wstring& msg) const;
1629#endif
1630#if LOG4CXX_UNICHAR_API
1644 void trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
1657 void trace(const std::basic_string<UniChar>& msg) const;
1658#endif
1659#if LOG4CXX_CFSTRING_API
1673 void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
1686 void trace(const CFStringRef& msg) const;
1687#endif
1701 void trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
1714 void trace(const std::string& msg) const;
1715
1722 void reconfigure( const std::vector<AppenderPtr>& appenders, bool additivity );
1723
1724 private:
1725 //
1726 // prevent copy and assignment
1727 Logger(const Logger&);
1728 Logger& operator=(const Logger&);
1729 mutable shared_mutex mutex;
1730 friend class log4cxx::helpers::synchronized;
1731};
1733
1734}
1735
1740#if !defined(LOG4CXX_UNLIKELY)
1741 #if __GNUC__ >= 3
1748 #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
1749 #else
1756 #define LOG4CXX_UNLIKELY(expr) expr
1757 #endif
1758#endif
1759
1760
1768#define LOG4CXX_LOG(logger, level, message) do { \
1769 if (logger->isEnabledFor(level)) {\
1770 ::log4cxx::helpers::MessageBuffer oss_; \
1771 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1772
1780#define LOG4CXX_LOG_FMT(logger, level, ...) do { \
1781 if (logger->isEnabledFor(level)) {\
1782 logger->forcedLog(level, fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1783
1791#define LOG4CXX_LOGLS(logger, level, message) do { \
1792 if (logger->isEnabledFor(level)) {\
1793 ::log4cxx::helpers::LogCharMessageBuffer oss_; \
1794 logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1795
1796#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
1803#define LOG4CXX_DEBUG(logger, message) do { \
1804 if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
1805 ::log4cxx::helpers::MessageBuffer oss_; \
1806 logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1807
1814#define LOG4CXX_DEBUG_FMT(logger, ...) do { \
1815 if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
1816 logger->forcedLog(::log4cxx::Level::getDebug(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1817#else
1818#define LOG4CXX_DEBUG(logger, message)
1819#define LOG4CXX_DEBUG_FMT(logger, ...)
1820#endif
1821
1822#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000
1829#define LOG4CXX_TRACE(logger, message) do { \
1830 if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\
1831 ::log4cxx::helpers::MessageBuffer oss_; \
1832 logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1833
1840#define LOG4CXX_TRACE_FMT(logger, ...) do { \
1841 if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\
1842 logger->forcedLog(::log4cxx::Level::getTrace(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1843#else
1844#define LOG4CXX_TRACE(logger, message)
1845#define LOG4CXX_TRACE_FMT(logger, ...)
1846#endif
1847
1848#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000
1855#define LOG4CXX_INFO(logger, message) do { \
1856 if (logger->isInfoEnabled()) {\
1857 ::log4cxx::helpers::MessageBuffer oss_; \
1858 logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1859
1867#define LOG4CXX_INFO_FMT(logger, ...) do { \
1868 if (logger->isInfoEnabled()) {\
1869 logger->forcedLog(::log4cxx::Level::getInfo(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1870#else
1871#define LOG4CXX_INFO(logger, message)
1872#define LOG4CXX_INFO_FMT(logger, ...)
1873#endif
1874
1875#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000
1882#define LOG4CXX_WARN(logger, message) do { \
1883 if (logger->isWarnEnabled()) {\
1884 ::log4cxx::helpers::MessageBuffer oss_; \
1885 logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1886
1893#define LOG4CXX_WARN_FMT(logger, ...) do { \
1894 if (logger->isWarnEnabled()) {\
1895 logger->forcedLog(::log4cxx::Level::getWarn(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1896#else
1897#define LOG4CXX_WARN(logger, message)
1898#define LOG4CXX_WARN_FMT(logger, ...)
1899#endif
1900
1901#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000
1908#define LOG4CXX_ERROR(logger, message) do { \
1909 if (logger->isErrorEnabled()) {\
1910 ::log4cxx::helpers::MessageBuffer oss_; \
1911 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1912
1919#define LOG4CXX_ERROR_FMT(logger, ...) do { \
1920 if (logger->isErrorEnabled()) {\
1921 logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1922
1930#define LOG4CXX_ASSERT(logger, condition, message) do { \
1931 if (!(condition) && logger->isErrorEnabled()) {\
1932 ::log4cxx::helpers::MessageBuffer oss_; \
1933 logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1934
1942#define LOG4CXX_ASSERT_FMT(logger, condition, ...) do { \
1943 if (!(condition) && logger->isErrorEnabled()) {\
1944 logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1945
1946#else
1947#define LOG4CXX_ERROR(logger, message)
1948#define LOG4CXX_ERROR_FMT(logger, ...)
1949#define LOG4CXX_ASSERT(logger, condition, message)
1950#define LOG4CXX_ASSERT_FMT(logger, condition, ...)
1951#endif
1952
1953#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000
1960#define LOG4CXX_FATAL(logger, message) do { \
1961 if (logger->isFatalEnabled()) {\
1962 ::log4cxx::helpers::MessageBuffer oss_; \
1963 logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
1964
1971#define LOG4CXX_FATAL_FMT(logger, ...) do { \
1972 if (logger->isFatalEnabled()) {\
1973 logger->forcedLog(::log4cxx::Level::getFatal(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
1974#else
1975#define LOG4CXX_FATAL(logger, message)
1976#define LOG4CXX_FATAL_FMT(logger, ...)
1977#endif
1978
1986#define LOG4CXX_L7DLOG(logger, level, key) do { \
1987 if (logger->isEnabledFor(level)) {\
1988 logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
1989
1998#define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \
1999 if (logger->isEnabledFor(level)) {\
2000 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
2001
2011#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \
2012 if (logger->isEnabledFor(level)) {\
2013 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
2014
2025#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \
2026 if (logger->isEnabledFor(level)) {\
2027 logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
2028
2031#if defined(_MSC_VER)
2032 #pragma warning ( pop )
2033#endif
2034
2036
2037#endif //_LOG4CXX_LOGGER_H
Definition: defaultloggerfactory.h:32
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
Definition: hierarchy.h:63
This is the central class in the log4cxx package.
Definition: logger.h:66
void log(const LevelPtr &level, const std::wstring &message) const
This is the most generic printing method.
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
Log a message string with the INFO level.
void setAdditivity(bool additive)
Set the additivity flag for this Logger instance.
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
Log a message string with the INFO level.
void l7dlog(const LevelPtr &level, const std::basic_string< UniChar > &key, const log4cxx::spi::LocationInfo &locationInfo, const std::basic_string< UniChar > &val1) const
Log a localized and parameterized message.
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
Log a message string with the WARN level.
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
Log a localized and parameterized message.
void info(const std::basic_string< UniChar > &msg) const
Log a message string with the INFO level.
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 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
This is the most generic printing method.
void error(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the ERROR level.
void warn(const std::basic_string< UniChar > &msg) const
Log a message string with the WARN level.
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
Log a message string with the DEBUG level.
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.
Definition: logger.h:1481
AppenderList getAllAppenders() const
Get the appenders contained in this logger as an AppenderList.
AppenderPtr getAppender(const LogString &name) const
Look for the appender named as name.
void warn(const std::string &msg) const
Log a message string with the WARN level.
void error(const std::wstring &msg) const
Log a message string with the ERROR level.
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
Log a localized and parameterized message.
void trace(const std::string &msg) const
Log a message string with the TRACE level.
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
Log a message string with the ERROR level.
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo, const std::wstring &val1) const
Log a localized and parameterized message.
void logLS(const LevelPtr &level, const LogString &message, const log4cxx::spi::LocationInfo &location) const
This is the most generic printing method.
static LoggerPtr getLogger(const char *const name)
Retrieve a logger by name in current encoding.
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo, const std::string &val1) const
Log a localized and parameterized message.
bool isInfoEnabled() const
Check whether this logger is enabled for the info Level.
void trace(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the TRACE level.
void removeAppender(const LogString &name)
Remove the appender with the name passed as parameter form the list of appenders.
log4cxx::spi::LoggerRepository * getLoggerRepository() const
Return the the LoggerRepository where this Logger is attached.
bool isFatalEnabled() const
Check whether this logger is enabled for the fatal Level.
void debug(const std::basic_string< UniChar > &msg) const
Log a message string with the DEBUG level.
void warn(const CFStringRef &msg) const
Log a message string with the WARN level.
void log(const LevelPtr &level, const CFStringRef &message) const
This is the most generic printing method.
virtual void setLevel(const LevelPtr level)
Set the level of this Logger.
void getName(std::wstring &name) const
Get logger name.
bool isWarnEnabled() const
Check whether this logger is enabled for the warn Level.
log4cxx::spi::LoggerRepository * repository
Definition: logger.h:105
void debug(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the DEBUG level.
void fatal(const CFStringRef &msg) const
Log a message string with the ERROR level.
void log(const LevelPtr &level, const std::basic_string< UniChar > &message) const
This is the most generic printing method.
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
Log a localized and parameterized message.
void log(const LevelPtr &level, const std::string &message) const
This is the most generic printing method.
void trace(const std::basic_string< UniChar > &msg) const
Log a message string with the TRACE level.
bool additive
Additivity is set to true by default, that is children inherit the appenders of their ancestors by de...
Definition: logger.h:116
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo) const
Log a localized and parameterized message.
void trace(const std::wstring &msg) const
Log a message string with the TRACE level.
void error(const std::string &msg) const
Log a message string with the ERROR level.
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo, const CFStringRef &val1, const CFStringRef &val2) const
Log a localized and parameterized message.
void fatal(const std::wstring &msg) const
Log a message string with the ERROR level.
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.
Definition: logger.h:633
LogString getResourceBundleString(const LogString &key) const
Returns the string resource coresponding to key in this logger's inherited resource bundle.
bool isEnabledFor(const LevelPtr &level) const
Check whether this logger is enabled for a given Level passed as parameter.
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
Log a message string with the DEBUG level.
void debug(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the DEBUG level.
void info(const std::string &msg) const
bool isAttached(const AppenderPtr appender) const
Is the appender passed as parameter attached to this logger?
void forcedLog(const LevelPtr &level, const std::basic_string< UniChar > &message, const log4cxx::spi::LocationInfo &location) const
This method creates a new logging event and logs the event without further checks.
void forcedLog(const LevelPtr &level, const std::basic_string< UniChar > &message) const
This method creates a new logging event and logs the event without further checks.
void error(const CFStringRef &msg) const
Log a message string with the ERROR level.
helpers::AppenderAttachableImplPtr aai
Definition: logger.h:107
void error(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the ERROR level.
void warn(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the WARN level.
void removeAllAppenders()
Remove all previously added appenders from this logger instance.
void warn(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the WARN level.
void forcedLog(const LevelPtr &level, const CFStringRef &message, const log4cxx::spi::LocationInfo &location) const
This method creates a new logging event and logs the event without further checks.
void forcedLog(const LevelPtr &level, const CFStringRef &message) const
This method creates a new logging event and logs the event without further checks.
void fatal(const std::string &msg) const
Log a message string with the ERROR level.
void log(const LevelPtr &level, const std::wstring &message, const log4cxx::spi::LocationInfo &location) const
This is the most generic printing method.
void warn(const std::wstring &msg) const
Log a message string with the WARN level.
void setHierarchy(spi::LoggerRepository *repository)
Only the Hierarchy class can set the hierarchy of a logger.
void debug(const std::wstring &msg) const
Log a message string with the DEBUG level.
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo) const
Log a localized and parameterized message.
void trace(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the TRACE level.
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo, const std::string &val1, const std::string &val2) const
Log a localized and parameterized message.
LoggerPtr parent
The parent of this logger.
Definition: logger.h:95
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
Log a message string with the ERROR level.
virtual void addAppender(const AppenderPtr newAppender)
Add newAppender to the list of appenders of this Logger instance.
void forcedLogLS(const LevelPtr &level, const LogString &message, const log4cxx::spi::LocationInfo &location) const
This method creates a new logging event and logs the event without further checks.
void error(const std::basic_string< UniChar > &msg) const
Log a message string with the ERROR level.
void fatal(const std::basic_string< UniChar > &msg) const
Log a message string with the ERROR level.
static LoggerPtr getLogger(const std::string &name)
Retrieve a logger by name in current encoding.
bool isDebugEnabled() const
Check whether this logger is enabled for the DEBUG Level.
void error(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the ERROR level.
void forcedLog(const LevelPtr &level, const std::wstring &message, const log4cxx::spi::LocationInfo &location) const
This method creates a new logging event and logs the event without further checks.
void info(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the INFO level.
void getName(std::string &name) const
Get logger name in current encoding.
void forcedLog(const LevelPtr &level, const std::wstring &message) const
This method creates a new logging event and logs the event without further checks.
void l7dlog(const LevelPtr &level, const std::basic_string< UniChar > &key, const log4cxx::spi::LocationInfo &locationInfo) const
Log a localized and parameterized message.
void fatal(const std::string &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the FATAL level.
void log(const LevelPtr &level, const std::string &message, const log4cxx::spi::LocationInfo &location) const
This is the most generic printing method.
void fatal(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the ERROR level.
void fatal(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the ERROR level.
bool getAdditivity() const
Get the additivity flag for this Logger instance.
void getName(CFStringRef &name) const
Get logger name.
static LoggerPtr getRootLogger()
Retrieve the root logger.
void trace(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the TRACE level.
helpers::ResourceBundlePtr resourceBundle
The resourceBundle for localized messages.
Definition: logger.h:101
void log(const LevelPtr &level, const CFStringRef &message, const log4cxx::spi::LocationInfo &location) const
This is the most generic printing method.
LevelPtr level
The assigned level of this logger.
Definition: logger.h:90
void warn(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the WARN level.
void trace(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the TRACE level.
LoggerPtr getParent() const
Returns the parent of this logger.
void l7dlog(const LevelPtr &level, const std::wstring &key, const log4cxx::spi::LocationInfo &locationInfo, const std::wstring &val1, const std::wstring &val2) const
Log a localized and parameterized message.
void l7dlog(const LevelPtr &level, const LogString &key, const log4cxx::spi::LocationInfo &locationInfo, const std::vector< LogString > &values) const
Log a localized and parameterized message.
void forcedLog(const LevelPtr &level, const std::string &message, const log4cxx::spi::LocationInfo &location) const
This method creates a new logging event and logs the event without further checks.
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
Log a localized and parameterized message.
void l7dlog(const LevelPtr &level, const std::string &key, const log4cxx::spi::LocationInfo &locationInfo) const
Log a localized and parameterized message.
void closeNestedAppenders()
Close all attached appenders implementing the AppenderAttachable interface.
void info(const CFStringRef &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the INFO level.
void info(const std::basic_string< UniChar > &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the INFO level.
Logger(log4cxx::helpers::Pool &pool, const LogString &name)
This constructor created a new logger instance and sets its name.
void info(const CFStringRef &msg) const
Log a message string with the INFO level.
void debug(const std::wstring &msg, const log4cxx::spi::LocationInfo &location) const
Log a message string with the DEBUG level.
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo, const CFStringRef &val1, const CFStringRef &val2, const CFStringRef &val3) const
Log a localized and parameterized message.
LevelPtr getLevel() const
Returns the assigned Level, if any, for this Logger.
void getName(std::basic_string< UniChar > &name) const
Get logger name.
void removeAppender(const AppenderPtr appender)
Remove the appender passed as parameter form the list of appenders.
LogString name
The name of this logger.
Definition: logger.h:84
void trace(const CFStringRef &msg) const
Log a message string with the TRACE level.
void l7dlog(const LevelPtr &level, const CFStringRef &key, const log4cxx::spi::LocationInfo &locationInfo, const CFStringRef &val1) const
Log a localized and parameterized message.
void debug(const std::string &msg) const
Log a message string with the DEBUG level.
void reconfigure(const std::vector< AppenderPtr > &appenders, bool additivity)
Reconfigure this logger by configuring all of the appenders.
bool isErrorEnabled() const
Check whether this logger is enabled for the error Level.
void forcedLog(const LevelPtr &level, const std::string &message) const
This method creates a new logging event and logs the event without further checks.
bool isTraceEnabled() const
Check whether this logger is enabled for the trace level.
base class for java-like objects.
Definition: object.h:102
Definition: pool.h:33
This Interface is for attaching Appenders to objects.
Definition: appenderattachable.h:39
This class represents the location of a logging statement.
Definition: locationinfo.h:47
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:48
const struct __CFString * CFStringRef
Definition: logstring.h:36
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:39
LOG4CXX_PTR_DEF(LoggerRepository)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:38
Definition: messagehandler.h:23
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr)
std::basic_string< logchar > LogString
Definition: logstring.h:66
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:34
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141