oflog/include/dcmtk/oflog/appender.h

Go to the documentation of this file.
00001 // Module:  Log4CPLUS
00002 // File:    appender.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_APPENDER_HEADER_
00024 #define _LOG4CPLUS_APPENDER_HEADER_
00025 
00026 #include "dcmtk/oflog/config.h"
00027 #include "dcmtk/oflog/layout.h"
00028 #include "dcmtk/oflog/loglevel.h"
00029 #include "dcmtk/oflog/tstring.h"
00030 #include "dcmtk/oflog/helpers/lloguser.h"
00031 #include "dcmtk/oflog/helpers/pointer.h"
00032 #include "dcmtk/oflog/helpers/property.h"
00033 #include "dcmtk/oflog/spi/filter.h"
00034 
00035 //#include <memory>
00036 #include "dcmtk/ofstd/ofaptr.h"
00037 
00038 
00039 namespace log4cplus {
00040 
00045     class LOG4CPLUS_EXPORT ErrorHandler {
00046     public:
00047         virtual ~ErrorHandler();
00048         virtual void error(const log4cplus::tstring& err) = 0;
00049         virtual void reset() = 0;
00050     };
00051 
00052 
00053 
00054     class LOG4CPLUS_EXPORT OnlyOnceErrorHandler : public ErrorHandler,
00055                                                   protected log4cplus::helpers::LogLogUser
00056     {
00057     public:
00058       // Ctor
00059         OnlyOnceErrorHandler() : firstTime(true){}
00060 
00061         virtual void error(const log4cplus::tstring& err);
00062         virtual void reset();
00063 
00064     private:
00065         bool firstTime;
00066     };
00067 
00068 
00073     class LOG4CPLUS_EXPORT Appender
00074         : public virtual log4cplus::helpers::SharedObject
00075         , protected log4cplus::helpers::LogLogUser
00076 
00077     {
00078     public:
00079       // Ctor
00080         Appender();
00081         Appender(const log4cplus::helpers::Properties properties);
00082 
00083       // Dtor
00084         virtual ~Appender();
00085 
00086         void destructorImpl();
00087 
00088       // Methods
00095         virtual void close() = 0;
00096 
00102         void doAppend(const log4cplus::spi::InternalLoggingEvent& event);
00103 
00108         virtual log4cplus::tstring getName();
00109 
00114         virtual void setName(const log4cplus::tstring& name);
00115 
00119         virtual void setErrorHandler(OFauto_ptr<ErrorHandler> eh);
00120 
00125         virtual ErrorHandler* getErrorHandler();
00126 
00132         virtual void setLayout(OFauto_ptr<Layout> layout);
00133 
00139         virtual Layout* getLayout();
00140 
00144         void setFilter(log4cplus::spi::FilterPtr f) { filter = f; }
00145 
00149         log4cplus::spi::FilterPtr getFilter() const { return filter; }
00150 
00155         LogLevel getThreshold() const { return threshold; }
00156 
00165         void setThreshold(LogLevel th) { threshold = th; }
00166 
00172         bool isAsSevereAsThreshold(LogLevel ll) const {
00173             return ((ll != NOT_SET_LOG_LEVEL) && (ll >= threshold));
00174         }
00175 
00176     protected:
00177       // Methods
00183         virtual void append(const log4cplus::spi::InternalLoggingEvent& event) = 0;
00184 
00185       // Data
00188         OFauto_ptr<Layout> layout;
00189 
00191         log4cplus::tstring name;
00192 
00194         LogLevel threshold;
00195 
00198         log4cplus::spi::FilterPtr filter;
00199 
00201         OFauto_ptr<ErrorHandler> errorHandler;
00202 
00204         bool closed;
00205     };
00206 
00208     typedef helpers::SharedObjectPtr<Appender> SharedAppenderPtr;
00209 
00210 } // end namespace log4cplus
00211 
00212 #endif // _LOG4CPLUS_APPENDER_HEADER_
00213 


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1