log4cplus
2.0.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: loggerimpl.h 00004 // Created: 6/2001 00005 // Author: Tad E. Smith 00006 // 00007 // 00008 // Copyright 2001-2015 Tad E. Smith 00009 // 00010 // Licensed under the Apache License, Version 2.0 (the "License"); 00011 // you may not use this file except in compliance with the License. 00012 // You may obtain a copy of the License at 00013 // 00014 // http://www.apache.org/licenses/LICENSE-2.0 00015 // 00016 // Unless required by applicable law or agreed to in writing, software 00017 // distributed under the License is distributed on an "AS IS" BASIS, 00018 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 // See the License for the specific language governing permissions and 00020 // limitations under the License. 00021 00024 #ifndef LOG4CPLUS_SPI_LOGGER_HEADER_ 00025 #define LOG4CPLUS_SPI_LOGGER_HEADER_ 00026 00027 #include <log4cplus/config.hxx> 00028 00029 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00030 #pragma once 00031 #endif 00032 00033 #include <log4cplus/tstring.h> 00034 #include <log4cplus/helpers/appenderattachableimpl.h> 00035 #include <log4cplus/helpers/pointer.h> 00036 #include <log4cplus/spi/loggerfactory.h> 00037 #include <memory> 00038 #include <vector> 00039 00040 00041 namespace log4cplus { 00042 class DefaultLoggerFactory; 00043 00044 namespace spi { 00045 00051 class LOG4CPLUS_EXPORT LoggerImpl 00052 : public virtual log4cplus::helpers::SharedObject, 00053 public log4cplus::helpers::AppenderAttachableImpl 00054 { 00055 public: 00056 typedef helpers::SharedObjectPtr<LoggerImpl> SharedLoggerImplPtr; 00057 00058 // Methods 00059 00071 virtual void callAppenders(const InternalLoggingEvent& event); 00072 00077 virtual void closeNestedAppenders(); 00078 00085 virtual bool isEnabledFor(LogLevel ll) const; 00086 00090 virtual void log(LogLevel ll, const log4cplus::tstring& message, 00091 const char* file=nullptr, int line=-1, 00092 const char* function=nullptr); 00093 00094 virtual void log(spi::InternalLoggingEvent const &); 00095 00104 virtual LogLevel getChainedLogLevel() const; 00105 00111 LogLevel getLogLevel() const { return this->ll; } 00112 00116 void setLogLevel(LogLevel _ll) { this->ll = _ll; } 00117 00122 virtual Hierarchy& getHierarchy() const; 00123 00127 log4cplus::tstring const & getName() const { return name; } 00128 00132 bool getAdditivity() const; 00133 00137 void setAdditivity(bool additive); 00138 00139 virtual ~LoggerImpl(); 00140 00141 protected: 00142 // Ctors 00153 LoggerImpl(const log4cplus::tstring& name, Hierarchy& h); 00154 00155 00156 // Methods 00161 virtual void forcedLog(LogLevel ll, 00162 const log4cplus::tstring& message, 00163 const char* file, 00164 int line, 00165 const char* function); 00166 00167 virtual void forcedLog(spi::InternalLoggingEvent const & ev); 00168 00169 00170 // Data 00172 log4cplus::tstring name; 00173 00177 LogLevel ll; 00178 00183 SharedLoggerImplPtr parent; 00184 00194 bool additive; 00195 00196 private: 00197 // Data 00199 Hierarchy& hierarchy; 00200 00201 // Disallow copying of instances of this class 00202 LoggerImpl(const LoggerImpl&) = delete; 00203 LoggerImpl& operator=(const LoggerImpl&) = delete; 00204 00205 // Friends 00206 friend class log4cplus::Logger; 00207 friend class log4cplus::DefaultLoggerFactory; 00208 friend class log4cplus::Hierarchy; 00209 }; 00210 00211 typedef LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr; 00212 00213 } // end namespace spi 00214 } // end namespace log4cplus 00215 00216 #endif // LOG4CPLUS_SPI_LOGGER_HEADER_