00001 // Module: Log4CPLUS 00002 // File: loggerimpl.h 00003 // Created: 6/2001 00004 // Author: Tad E. Smith 00005 // 00006 // 00007 // Copyright 2001-2009 Tad E. Smith 00008 // 00009 // Licensed under the Apache License, Version 2.0 (the "License"); 00010 // you may not use this file except in compliance with the License. 00011 // You may obtain a copy of the License at 00012 // 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // 00015 // Unless required by applicable law or agreed to in writing, software 00016 // distributed under the License is distributed on an "AS IS" BASIS, 00017 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 // See the License for the specific language governing permissions and 00019 // limitations under the License. 00020 00023 #ifndef _LOG4CPLUS_SPI_LOGGER_HEADER_ 00024 #define _LOG4CPLUS_SPI_LOGGER_HEADER_ 00025 00026 #include "dcmtk/oflog/config.h" 00027 #include "dcmtk/oflog/tstring.h" 00028 #include "dcmtk/oflog/helpers/apndimpl.h" 00029 #include "dcmtk/oflog/helpers/pointer.h" 00030 #include "dcmtk/oflog/spi/logfact.h" 00031 //#include <memory> 00032 //#include <vector> 00033 00034 00035 namespace log4cplus { 00036 class DefaultLoggerFactory; 00037 00038 namespace spi { 00039 00048 class LOG4CPLUS_EXPORT LoggerImpl 00049 : public virtual log4cplus::helpers::SharedObject, 00050 public log4cplus::helpers::AppenderAttachableImpl 00051 { 00052 public: 00053 typedef helpers::SharedObjectPtr<LoggerImpl> SharedLoggerImplPtr; 00054 00055 // Methods 00056 00068 virtual void callAppenders(const InternalLoggingEvent& event); 00069 00074 virtual void closeNestedAppenders(); 00075 00082 virtual bool isEnabledFor(LogLevel ll) const; 00083 00087 virtual void log(LogLevel ll, const log4cplus::tstring& message, 00088 const char* file=NULL, int line=-1, 00089 const char* function=NULL); 00090 00099 virtual LogLevel getChainedLogLevel() const; 00100 00106 LogLevel getLogLevel() const { return this->ll; } 00107 00111 void setLogLevel(LogLevel _ll) { this->ll = _ll; } 00112 00117 virtual Hierarchy& getHierarchy() const; 00118 00122 log4cplus::tstring getName() const { return name; } 00123 00127 bool getAdditivity() const; 00128 00132 void setAdditivity(bool additive); 00133 00134 virtual ~LoggerImpl(); 00135 00136 protected: 00137 // Ctors 00148 LoggerImpl(const log4cplus::tstring& name, Hierarchy& h); 00149 00150 00151 // Methods 00156 virtual void forcedLog(LogLevel ll, 00157 const log4cplus::tstring& message, 00158 const char* file=NULL, 00159 int line=-1, 00160 const char* function=NULL); 00161 00162 00163 // Data 00165 log4cplus::tstring name; 00166 00170 LogLevel ll; 00171 00176 SharedLoggerImplPtr parent; 00177 00187 bool additive; 00188 00189 private: 00190 // Data 00192 Hierarchy& hierarchy; 00193 00194 // Disallow copying of instances of this class 00195 LoggerImpl(const LoggerImpl&); 00196 LoggerImpl& operator=(const LoggerImpl&); 00197 00198 // Friends 00199 friend class log4cplus::Logger; 00200 friend class log4cplus::DefaultLoggerFactory; 00201 friend class log4cplus::Hierarchy; 00202 }; 00203 00204 typedef LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr; 00205 00206 } // end namespace spi 00207 } // end namespace log4cplus 00208 00209 #endif // _LOG4CPLUS_SPI_LOGGER_HEADER_ 00210 00211