activemq-cpp-3.3.0

src/main/decaf/util/logging/Handler.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef _DECAF_UTIL_LOGGING_HANDLER_H_
00018 #define _DECAF_UTIL_LOGGING_HANDLER_H_
00019 
00020 #include <decaf/io/Closeable.h>
00021 #include <decaf/lang/Exception.h>
00022 #include <decaf/util/logging/LogRecord.h>
00023 #include <decaf/util/logging/Level.h>
00024 #include <decaf/lang/exceptions/NullPointerException.h>
00025 
00026 #include <string>
00027 
00028 namespace decaf{
00029 namespace util{
00030 namespace logging{
00031 
00032     class Filter;
00033     class Formatter;
00034     class ErrorManager;
00035 
00049     class DECAF_API Handler : public io::Closeable {
00050     private:
00051 
00052         // Default Logging Level for Handler
00053         static const Level DEFAULT_LEVEL;
00054 
00055         // Formats this Handlers output
00056         Formatter* formatter;
00057 
00058         // Filter object for Log Filtering
00059         Filter* filter;
00060 
00061         // ErrorManager instance for this Handler
00062         ErrorManager* errorManager;
00063 
00064         // Level at which that this Handler will start logging.
00065         Level level;
00066 
00067         // Name of this class used to read properties
00068         std::string prefix;
00069 
00070     private:
00071 
00072         Handler( const Handler& );
00073         Handler& operator= ( const Handler& );
00074 
00075     public:
00076 
00077         Handler();
00078 
00079         virtual ~Handler();
00080 
00084         virtual void flush() = 0;
00085 
00090         virtual void publish( const LogRecord& record ) = 0;
00091 
00101         virtual bool isLoggable( const LogRecord& record ) const;
00102 
00112         virtual void setFilter( Filter* filter ) {
00113             this->filter = filter;
00114         }
00115 
00120         virtual Filter* getFilter() {
00121             return this->filter;
00122         }
00123 
00132         virtual void setLevel( const Level& value ) {
00133             this->level = value;
00134         }
00135 
00141         virtual Level getLevel() {
00142             return this->level;
00143         }
00144 
00152         virtual void setFormatter( Formatter* formatter );
00153 
00158         virtual Formatter* getFormatter() {
00159             return this->formatter;
00160         }
00161 
00170         virtual void setErrorManager( ErrorManager* errorManager );
00171 
00176         virtual ErrorManager* getErrorManager() {
00177             return this->errorManager;
00178         }
00179 
00180     protected:
00181 
00189         void reportError( const std::string& message, decaf::lang::Exception* ex, int code );
00190 
00191     };
00192 
00193 }}}
00194 
00195 #endif /*_DECAF_UTIL_LOGGING_HANDLER_H_*/