activemq-cpp-3.6.0
Handler.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef _DECAF_UTIL_LOGGING_HANDLER_H_
18 #define _DECAF_UTIL_LOGGING_HANDLER_H_
19 
20 #include <decaf/io/Closeable.h>
21 #include <decaf/lang/Exception.h>
25 
26 #include <string>
27 
28 namespace decaf{
29 namespace util{
30 namespace logging{
31 
32  class Filter;
33  class Formatter;
34  class ErrorManager;
35 
49  class DECAF_API Handler : public io::Closeable {
50  private:
51 
52  // Formats this Handlers output
53  Formatter* formatter;
54 
55  // Filter object for Log Filtering
56  Filter* filter;
57 
58  // ErrorManager instance for this Handler
59  ErrorManager* errorManager;
60 
61  // Level at which that this Handler will start logging.
62  Level level;
63 
64  // Name of this class used to read properties
65  std::string prefix;
66 
67  private:
68 
69  Handler( const Handler& );
70  Handler& operator= ( const Handler& );
71 
72  public:
73 
74  Handler();
75 
76  virtual ~Handler();
77 
81  virtual void flush() = 0;
82 
87  virtual void publish( const LogRecord& record ) = 0;
88 
98  virtual bool isLoggable( const LogRecord& record ) const;
99 
109  virtual void setFilter( Filter* filter ) {
110  this->filter = filter;
111  }
112 
117  virtual Filter* getFilter() {
118  return this->filter;
119  }
120 
129  virtual void setLevel( const Level& value ) {
130  this->level = value;
131  }
132 
138  virtual Level getLevel() {
139  return this->level;
140  }
141 
149  virtual void setFormatter( Formatter* formatter );
150 
155  virtual Formatter* getFormatter() {
156  return this->formatter;
157  }
158 
167  virtual void setErrorManager( ErrorManager* errorManager );
168 
174  return this->errorManager;
175  }
176 
177  protected:
178 
186  void reportError( const std::string& message, decaf::lang::Exception* ex, int code );
187 
188  };
189 
190 }}}
191 
192 #endif /*_DECAF_UTIL_LOGGING_HANDLER_H_*/