orca-robotics INTRODUCTION Overview Download and Install Documentation REPOSITORY Interfaces Drivers Libraries Utilities Software Map DEVELOPER 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-2008 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 <gbxsickacfr/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 SysLogger; 00026 } 00027 00033 class LocalTracer : public gbxsickacfr::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 gbxsickacfr::gbxutilacfr::Tracer 00044 virtual void print( const std::string &message ); 00045 virtual void info( const std::string &message, int level=1 ); 00046 virtual void warning( const std::string &message, int level=1 ); 00047 virtual void error( const std::string &message, int level=1 ); 00048 virtual void debug( const std::string &message, int level=1 ); 00049 virtual int verbosity( TraceType traceType, DestinationType destType ) const; 00050 00051 // experimental! 00052 virtual void setLevel( const std::string &subsystem, int level=0 ); 00053 virtual void debug( const std::string &subsystem, const std::string &message, int level=1 ); 00054 00055 protected: 00056 00057 Tracer::Config config_; 00058 std::string prefix_; 00059 00060 // custom outgoing commands 00061 void toDisplay( const std::string& category, const std::string& message, int level ); 00062 00063 // to file 00064 void toFile( const std::string& category, const std::string& message, int level ); 00065 00066 // to log 00067 void toLog( const std::string& category, const std::string& message, int level ); 00068 00069 std::string prevWarning_; 00070 std::string prevError_; 00071 00072 // We only have one communicator but may have multiple threads. 00073 IceUtil::Mutex mutex_; 00074 00075 // utilities, not thread-safe! 00076 void setDefaults(); 00077 void parseConfig(); 00078 void assembleMessage( const std::string& category, const std::string& message, int level, std::string& s ); 00079 void recalcMarginals(); 00080 00081 private: 00082 00083 hydroutil::Properties properties_; 00084 std::ofstream *file_; 00085 detail::SysLogger *sysLogger_; 00086 00087 // experimental 00088 std::map<std::string,int> subsysVerbosity_; 00089 }; 00090 00091 } // namespace 00092 00093 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)