activemq-cpp-3.8.2
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_*/
The Level class defines a set of standard logging levels that can be used to control logging output...
Definition: Level.h:56
virtual Formatter * getFormatter()
Gets the Formatter used by this Handler.
Definition: Handler.h:155
LogRecord objects are used to pass logging requests between the logging framework and individual log ...
Definition: LogRecord.h:41
A Filter can be used to provide fine grain control over what is logged, beyond the control provided b...
Definition: Filter.h:35
virtual void setFilter(Filter *filter)
Sets the Filter that this Handler uses to filter Log Records.
Definition: Handler.h:109
A Formatter provides support for formatting LogRecords.
Definition: Formatter.h:37
ErrorManager objects can be attached to Handlers to process any error that occur on a Handler during ...
Definition: ErrorManager.h:42
virtual Level getLevel()
Get the log level specifying which message levels will be logged by this Handler. ...
Definition: Handler.h:138
virtual void setLevel(const Level &value)
Set the log level specifying which message levels will be logged by this Handler. ...
Definition: Handler.h:129
Interface for a class that implements the close method.
Definition: Closeable.h:30
A Handler object takes log messages from a Logger and exports them.
Definition: Handler.h:49
Definition: inftrees.h:24
virtual ErrorManager * getErrorManager()
Gets the ErrorManager used by this Handler.
Definition: Handler.h:173
#define DECAF_API
Definition: Config.h:29
Definition: Exception.h:38
virtual Filter * getFilter()
Gets the Filter that this Handler uses to filter Log Records.
Definition: Handler.h:117
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25