log4cplus  1.1.0
loggerimpl.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Module:  Log4CPLUS
00003 // File:    loggerimpl.h
00004 // Created: 6/2001
00005 // Author:  Tad E. Smith
00006 //
00007 //
00008 // Copyright 2001-2010 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 
00054         class LOG4CPLUS_EXPORT LoggerImpl
00055             : public virtual log4cplus::helpers::SharedObject,
00056               public log4cplus::helpers::AppenderAttachableImpl
00057         {
00058         public:
00059             typedef helpers::SharedObjectPtr<LoggerImpl> SharedLoggerImplPtr;
00060 
00061           // Methods
00062 
00074             virtual void callAppenders(const InternalLoggingEvent& event);
00075 
00080             virtual void closeNestedAppenders();
00081 
00088             virtual bool isEnabledFor(LogLevel ll) const;
00089 
00093             virtual void log(LogLevel ll, const log4cplus::tstring& message,
00094                              const char* file=NULL, int line=-1);
00095 
00096             virtual void log(spi::InternalLoggingEvent const &);
00097 
00106             virtual LogLevel getChainedLogLevel() const;
00107 
00113             LogLevel getLogLevel() const { return this->ll; }
00114 
00118             void setLogLevel(LogLevel _ll) { this->ll = _ll; }
00119 
00124             virtual Hierarchy& getHierarchy() const;
00125 
00129             log4cplus::tstring const & getName() const { return name; }
00130 
00134             bool getAdditivity() const;
00135 
00139             void setAdditivity(bool additive);
00140 
00141             virtual ~LoggerImpl();
00142 
00143         protected:
00144           // Ctors
00155             LoggerImpl(const log4cplus::tstring& name, Hierarchy& h);
00156 
00157 
00158           // Methods
00163             virtual void forcedLog(LogLevel ll,
00164                                    const log4cplus::tstring& message,
00165                                    const char* file=NULL, 
00166                                    int line=-1);
00167 
00168             virtual void forcedLog(spi::InternalLoggingEvent const & ev);
00169 
00170 
00171           // Data
00173             log4cplus::tstring name;
00174 
00178             LogLevel ll;
00179 
00184             SharedLoggerImplPtr parent;
00185 
00195             bool additive;
00196 
00197         private:
00198           // Data
00200             Hierarchy& hierarchy;
00201 
00202           // Disallow copying of instances of this class
00203             LoggerImpl(const LoggerImpl&);
00204             LoggerImpl& operator=(const LoggerImpl&);
00205 
00206           // Friends
00207             friend class log4cplus::Logger;
00208             friend class log4cplus::DefaultLoggerFactory;
00209             friend class log4cplus::Hierarchy;
00210         };
00211 
00212         typedef LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr;
00213 
00214     } // end namespace spi
00215 } // end namespace log4cplus
00216 
00217 #endif // LOG4CPLUS_SPI_LOGGER_HEADER_
00218 
00219