INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
tracer.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://!gearbox.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 GBXUTILACFR_TRACER_H 00012 #define GBXUTILACFR_TRACER_H 00013 00014 #include <string> 00015 00016 namespace gbxutilacfr { 00017 00062 class Tracer 00063 { 00064 public: 00065 virtual ~Tracer() {}; 00066 00068 enum TraceType { 00070 InfoTrace=0, 00072 WarningTrace, 00074 ErrorTrace, 00076 DebugTrace, 00079 AnyTrace, 00081 NumberOfTraceTypes, 00085 OtherTrace 00086 }; 00087 00089 enum DestinationType { 00091 ToDisplay=0, 00093 ToNetwork, 00095 ToLog, 00097 ToFile, 00100 ToAny, 00102 NumberOfDestinationTypes 00103 }; 00104 00105 struct Config 00106 { 00108 int verbosity[NumberOfTraceTypes][NumberOfDestinationTypes]; 00110 bool addTimestamp; 00111 }; 00112 00114 00117 virtual void print( const std::string &message ) = 0; 00118 00120 virtual void info( const std::string &message, int level=1 ) = 0; 00121 00123 virtual void warning( const std::string &message, int level=1 ) = 0; 00124 00126 virtual void error( const std::string &message, int level=1 ) = 0; 00127 00129 virtual void debug( const std::string &message, int level=1 ) = 0; 00130 00136 virtual int verbosity( TraceType traceType, DestinationType destType ) const = 0; 00137 00138 static std::string toString( Tracer::TraceType type ) 00139 { 00140 switch ( type ) 00141 { 00142 case Tracer::InfoTrace : 00143 return "info"; 00144 case Tracer::WarningTrace : 00145 return "warn"; 00146 case Tracer::ErrorTrace : 00147 return "error"; 00148 case Tracer::DebugTrace : 00149 return "debug"; 00150 default : 00151 return "other"; 00152 } 00153 }; 00154 00155 static Tracer::TraceType toTraceType( const std::string& category ) 00156 { 00157 if ( category==std::string("info") ) 00158 return Tracer::InfoTrace; 00159 else if ( category==std::string("warn") ) 00160 return Tracer::WarningTrace; 00161 else if ( category==std::string("error") ) 00162 return Tracer::ErrorTrace; 00163 else if ( category==std::string("debug") ) 00164 return Tracer::DebugTrace; 00165 else 00166 return Tracer::OtherTrace; 00167 }; 00168 00169 00172 virtual void setLevel( const std::string &subsystem, int level=0 ) {}; 00173 00177 virtual void debug( const std::string &subsystem, const std::string &message, int level=1 ) 00178 { 00179 debug( message, level ); 00180 }; 00181 }; 00182 00183 } 00184 00185 #endif |