OFFIS DCMTK  Version 3.6.0
appender.h
Go to the documentation of this file.
1 // Module: Log4CPLUS
2 // File: appender.h
3 // Created: 6/2001
4 // Author: Tad E. Smith
5 //
6 //
7 // Copyright 2001-2009 Tad E. Smith
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 
23 #ifndef _LOG4CPLUS_APPENDER_HEADER_
24 #define _LOG4CPLUS_APPENDER_HEADER_
25 
26 #include "dcmtk/oflog/config.h"
27 #include "dcmtk/oflog/layout.h"
28 #include "dcmtk/oflog/loglevel.h"
29 #include "dcmtk/oflog/tstring.h"
33 #include "dcmtk/oflog/spi/filter.h"
34 
35 //#include <memory>
36 #include "dcmtk/ofstd/ofaptr.h"
37 
38 
39 namespace log4cplus {
40 
45  class LOG4CPLUS_EXPORT ErrorHandler {
46  public:
47  virtual ~ErrorHandler();
48  virtual void error(const log4cplus::tstring& err) = 0;
49  virtual void reset() = 0;
50  };
51 
52 
53 
54  class LOG4CPLUS_EXPORT OnlyOnceErrorHandler : public ErrorHandler,
56  {
57  public:
58  // Ctor
59  OnlyOnceErrorHandler() : firstTime(true){}
60 
61  virtual void error(const log4cplus::tstring& err);
62  virtual void reset();
63 
64  private:
65  bool firstTime;
66  };
67 
68 
73  class LOG4CPLUS_EXPORT Appender
74  : public virtual log4cplus::helpers::SharedObject
76 
77  {
78  public:
79  // Ctor
80  Appender();
81  Appender(const log4cplus::helpers::Properties properties);
82 
83  // Dtor
84  virtual ~Appender();
85 
86  void destructorImpl();
87 
88  // Methods
95  virtual void close() = 0;
96 
102  void doAppend(const log4cplus::spi::InternalLoggingEvent& event);
103 
108  virtual log4cplus::tstring getName();
109 
114  virtual void setName(const log4cplus::tstring& name);
115 
119  virtual void setErrorHandler(OFauto_ptr<ErrorHandler> eh);
120 
125  virtual ErrorHandler* getErrorHandler();
126 
132  virtual void setLayout(OFauto_ptr<Layout> layout);
133 
139  virtual Layout* getLayout();
140 
144  void setFilter(log4cplus::spi::FilterPtr f) { filter = f; }
145 
149  log4cplus::spi::FilterPtr getFilter() const { return filter; }
150 
155  LogLevel getThreshold() const { return threshold; }
156 
165  void setThreshold(LogLevel th) { threshold = th; }
166 
172  bool isAsSevereAsThreshold(LogLevel ll) const {
173  return ((ll != NOT_SET_LOG_LEVEL) && (ll >= threshold));
174  }
175 
176  protected:
177  // Methods
183  virtual void append(const log4cplus::spi::InternalLoggingEvent& event) = 0;
184 
185  // Data
189 
192 
194  LogLevel threshold;
195 
199 
202 
204  bool closed;
205  };
206 
209 
210 } // end namespace log4cplus
211 
212 #endif // _LOG4CPLUS_APPENDER_HEADER_
213 


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2