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 // Formats this Handlers output 00053 Formatter* formatter; 00054 00055 // Filter object for Log Filtering 00056 Filter* filter; 00057 00058 // ErrorManager instance for this Handler 00059 ErrorManager* errorManager; 00060 00061 // Level at which that this Handler will start logging. 00062 Level level; 00063 00064 // Name of this class used to read properties 00065 std::string prefix; 00066 00067 private: 00068 00069 Handler( const Handler& ); 00070 Handler& operator= ( const Handler& ); 00071 00072 public: 00073 00074 Handler(); 00075 00076 virtual ~Handler(); 00077 00081 virtual void flush() = 0; 00082 00087 virtual void publish( const LogRecord& record ) = 0; 00088 00098 virtual bool isLoggable( const LogRecord& record ) const; 00099 00109 virtual void setFilter( Filter* filter ) { 00110 this->filter = filter; 00111 } 00112 00117 virtual Filter* getFilter() { 00118 return this->filter; 00119 } 00120 00129 virtual void setLevel( const Level& value ) { 00130 this->level = value; 00131 } 00132 00138 virtual Level getLevel() { 00139 return this->level; 00140 } 00141 00149 virtual void setFormatter( Formatter* formatter ); 00150 00155 virtual Formatter* getFormatter() { 00156 return this->formatter; 00157 } 00158 00167 virtual void setErrorManager( ErrorManager* errorManager ); 00168 00173 virtual ErrorManager* getErrorManager() { 00174 return this->errorManager; 00175 } 00176 00177 protected: 00178 00186 void reportError( const std::string& message, decaf::lang::Exception* ex, int code ); 00187 00188 }; 00189 00190 }}} 00191 00192 #endif /*_DECAF_UTIL_LOGGING_HANDLER_H_*/
1.6.1