|
activemq-cpp-3.3.0
|
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_LOGGER_H_ 00018 #define _DECAF_UTIL_LOGGING_LOGGER_H_ 00019 00020 #include <decaf/util/logging/LoggerCommon.h> 00021 #include <decaf/util/logging/LogRecord.h> 00022 #include <decaf/util/logging/LogManager.h> 00023 #include <decaf/util/logging/Handler.h> 00024 #include <decaf/util/concurrent/Mutex.h> 00025 #include <decaf/util/Config.h> 00026 00027 #include <decaf/lang/exceptions/IllegalArgumentException.h> 00028 #include <decaf/lang/exceptions/NullPointerException.h> 00029 00030 #include <list> 00031 #include <string> 00032 #include <stdarg.h> 00033 00034 namespace decaf{ 00035 namespace util{ 00036 namespace logging{ 00037 00038 class Filter; 00039 00086 class DECAF_API Logger { 00087 private: 00088 00089 // The name of this Logger 00090 std::string name; 00091 00092 // The Parent of this Logger 00093 Logger* parent; 00094 00095 // list of Handlers owned by this logger 00096 std::list<Handler*> handlers; 00097 00098 // Filter used by this Logger 00099 Filter* filter; 00100 00101 // The Log Level of this Logger 00102 Level level; 00103 00104 // Using Parent Handlers? 00105 bool useParentHandlers; 00106 00107 private: 00108 00109 Logger( const Logger& ); 00110 Logger& operator= ( const Logger& ); 00111 00112 protected: 00113 00126 Logger( const std::string& name ); 00127 00128 public: 00129 00130 virtual ~Logger(); 00131 00136 const std::string& getName() const { 00137 return name; 00138 } 00139 00148 Logger* getParent() const { 00149 return this->parent; 00150 } 00151 00158 void setParent( Logger* parent ) { 00159 this->parent = parent; 00160 } 00161 00178 void addHandler( Handler* handler ); 00179 00188 void removeHandler( Handler* handler ); 00189 00195 const std::list<Handler*>& getHandlers() const; 00196 00208 void setFilter( Filter* filter ); 00209 00214 const Filter* getFilter() const { 00215 return filter; 00216 } 00217 00225 Level getLevel() const { 00226 return level; 00227 } 00228 00242 void setLevel( const Level& level ) { 00243 this->level = level; 00244 } 00245 00251 bool getUseParentHandlers() const { 00252 return useParentHandlers; 00253 } 00254 00264 void setUseParentHandlers( bool value ) { 00265 this->useParentHandlers = value; 00266 } 00267 00268 public: // Logging Methods. 00269 00283 virtual void entering( const std::string& blockName, 00284 const std::string& file, 00285 const int line ); 00286 00300 virtual void exiting( const std::string& blockName, 00301 const std::string& file, 00302 const int line ); 00303 00319 virtual void severe( const std::string& file, 00320 const int line, 00321 const std::string functionName, 00322 const std::string& message ); 00323 00339 virtual void warning( const std::string& file, 00340 const int line, 00341 const std::string functionName, 00342 const std::string& message ); 00343 00359 virtual void info( const std::string& file, 00360 const int line, 00361 const std::string functionName, 00362 const std::string& message ); 00363 00379 virtual void debug( const std::string& file, 00380 const int line, 00381 const std::string functionName, 00382 const std::string& message ); 00383 00399 virtual void config( const std::string& file, 00400 const int line, 00401 const std::string functionName, 00402 const std::string& message ); 00403 00419 virtual void fine( const std::string& file, 00420 const int line, 00421 const std::string functionName, 00422 const std::string& message ); 00423 00439 virtual void finer( const std::string& file, 00440 const int line, 00441 const std::string functionName, 00442 const std::string& message ); 00443 00459 virtual void finest( const std::string& file, 00460 const int line, 00461 const std::string functionName, 00462 const std::string& message ); 00463 00483 virtual void throwing( const std::string& file, 00484 const int line, 00485 const std::string functionName, 00486 const decaf::lang::Throwable& thrown ); 00487 00495 virtual bool isLoggable( const Level& level ) const; 00496 00504 virtual void log( LogRecord& record ); 00505 00515 virtual void log( const Level& level, const std::string& message ); 00516 00529 virtual void log( const Level& levels, 00530 const std::string& file, 00531 const int line, 00532 const std::string& message, ... ); 00533 00549 virtual void log( const Level& level, 00550 const std::string& file, 00551 const int line, 00552 const std::string& message, 00553 lang::Exception& ex ); 00554 00555 public: 00556 00571 static Logger* getAnonymousLogger(); 00572 00588 static Logger* getLogger( const std::string& name ); 00589 00590 }; 00591 00592 }}} 00593 00594 #endif /*_DECAF_UTIL_LOGGING_LOGGER_H_*/