INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
localtracer.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef HYDROICEUTIL_LOCAL_TRACER_H 00012 #define HYDROICEUTIL_LOCAL_TRACER_H 00013 00014 #include <gbxutilacfr/tracer.h> 00015 #include <hydroutil/properties.h> 00016 #include <hydroutil/uncopyable.h> 00017 00018 #include <map> 00019 #include <IceUtil/Mutex.h> 00020 00021 namespace hydroiceutil 00022 { 00023 00024 namespace detail { 00025 class TracerLogWriter; 00026 } 00027 00033 class LocalTracer : public gbxutilacfr::Tracer, 00034 public hydroutil::Uncopyable 00035 { 00036 public: 00038 LocalTracer(); 00040 LocalTracer( const hydroutil::Properties& props, const std::string& sysName="Tracer" ); 00041 virtual ~LocalTracer(); 00042 00043 // from gbxutilacfr::Tracer 00044 virtual void print( const std::string &message ); 00045 virtual void info( const std::string &message, int level=1, bool localOnly=false ) 00046 { info("",message,level,localOnly); } 00047 virtual void warning( const std::string &message, int level=1, bool localOnly=false ) 00048 { warning("",message,level,localOnly); } 00049 virtual void error( const std::string &message, int level=1, bool localOnly=false ) 00050 { error("",message,level,localOnly); } 00051 virtual void debug( const std::string &message, int level=1, bool localOnly=false ) 00052 { debug("",message,level,localOnly); } 00053 virtual int verbosity( gbxutilacfr::TraceType traceType, gbxutilacfr::DestinationType destType ) const; 00054 00055 virtual void info( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ); 00056 virtual void warning( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ); 00057 virtual void error( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ); 00058 virtual void debug( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ); 00059 00060 // experimental! 00061 virtual void setSubsystemDebugLevel( const std::string &subsystem, int level=0 ); 00062 virtual void subsystemDebug( const std::string &subsystem, const std::string &message, int level=1 ); 00063 00064 protected: 00065 00066 std::string prefix_; 00067 00068 // locking config_ 00069 IceUtil::Mutex mutex_; 00070 Tracer::Config config_; 00071 00072 // recalculates "marginal" verbosity levels, i.e. [...][ToAny] and [AnyTrace][...] 00073 // not thread safe. 00074 void recalcMarginals(); 00075 00076 // destination functions 00077 void toDisplay( gbxutilacfr::TraceType type, 00078 const std::string &message, 00079 int level, 00080 const std::string &subsystem="" ); 00081 void toFile( gbxutilacfr::TraceType type, 00082 const std::string &message, 00083 int level, 00084 const std::string &subsystem="" ); 00085 void toLog( gbxutilacfr::TraceType type, 00086 const std::string &message, 00087 int level, 00088 const std::string &subsystem="" ); 00091 virtual void toNetwork( gbxutilacfr::TraceType type, 00092 const std::string &message, 00093 int level, 00094 const std::string &subsytem = "" ) {}; 00095 00096 private: 00097 00098 // this is the workhorse which actually distributes traces to destinations. 00099 // thread safe. 00100 void distribute( gbxutilacfr::TraceType type, 00101 const std::string &message, 00102 const std::string &subsystem, 00103 int level, 00104 bool localOnly = false ); 00105 00106 // utilities, not thread-safe! 00107 void setDefaults(); 00108 void parseConfig(); 00109 std::string assembleDisplayOrFileMessage( gbxutilacfr::TraceType type, 00110 const std::string &message, 00111 const std::string &subsystem, 00112 int level ); 00113 00114 hydroutil::Properties properties_; 00115 std::ofstream *file_; 00116 detail::TracerLogWriter *tracerLogWriter_; 00117 00118 // experimental 00119 std::map<std::string,int> subsysVerbosity_; 00120 }; 00121 00122 } // namespace 00123 00124 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)