From: <bo...@us...> - 2008-10-16 06:14:35
|
Revision: 325 http://gearbox.svn.sourceforge.net/gearbox/?rev=325&view=rev Author: borax00 Date: 2008-10-16 06:14:30 +0000 (Thu, 16 Oct 2008) Log Message: ----------- allowed different levels for trivialTracer. Modified Paths: -------------- gearbox/trunk/src/gbxgarminacfr/test/test.cpp gearbox/trunk/src/gbxsickacfr/test/test.cpp gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp gearbox/trunk/src/gbxsmartbatteryacfr/test/shorttest.cpp gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp gearbox/trunk/src/gbxutilacfr/trivialtracer.h Modified: gearbox/trunk/src/gbxgarminacfr/test/test.cpp =================================================================== --- gearbox/trunk/src/gbxgarminacfr/test/test.cpp 2008-10-16 05:24:14 UTC (rev 324) +++ gearbox/trunk/src/gbxgarminacfr/test/test.cpp 2008-10-16 06:14:30 UTC (rev 325) @@ -66,9 +66,9 @@ cout << "Using configuration: " << config.toString() << endl; // Instantiate objects to handle messages from the driver - bool debug = true; + bool debug = 5; if ( quiet ) - debug = false; + debug = 0; gbxutilacfr::TrivialTracer tracer( debug ); gbxutilacfr::TrivialStatus status( tracer ); Modified: gearbox/trunk/src/gbxsickacfr/test/test.cpp =================================================================== --- gearbox/trunk/src/gbxsickacfr/test/test.cpp 2008-10-16 05:24:14 UTC (rev 324) +++ gearbox/trunk/src/gbxsickacfr/test/test.cpp 2008-10-16 06:14:30 UTC (rev 325) @@ -31,7 +31,7 @@ int opt; int baud = 38400; string port = "/dev/ttyS0"; - bool debug = false; + bool debug = 0; bool showScan = false; // Get some options from the command line @@ -46,7 +46,7 @@ baud = atoi( optarg ); break; case 'v': - debug = true; + debug = 5; break; case 's': showScan = true; Modified: gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp =================================================================== --- gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp 2008-10-16 05:24:14 UTC (rev 324) +++ gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp 2008-10-16 06:14:30 UTC (rev 325) @@ -8,7 +8,7 @@ { int opt; std::string port = "/dev/ttyS0"; - bool debug = false; + int debug = 0; // Get some options from the command line while ((opt = getopt(argc, argv, "p:v")) != -1) @@ -19,7 +19,7 @@ port = optarg; break; case 'v': - debug = true; + debug = 5; break; default: cout << "Usage: " << argv[0] << " [-p port] [-v(erbose)]" << endl Modified: gearbox/trunk/src/gbxsmartbatteryacfr/test/shorttest.cpp =================================================================== --- gearbox/trunk/src/gbxsmartbatteryacfr/test/shorttest.cpp 2008-10-16 05:24:14 UTC (rev 324) +++ gearbox/trunk/src/gbxsmartbatteryacfr/test/shorttest.cpp 2008-10-16 06:14:30 UTC (rev 325) @@ -8,7 +8,7 @@ { int opt; std::string port = "/dev/ttyS0"; - bool debug = false; + int debug = 0; // Get some options from the command line while ((opt = getopt(argc, argv, "p:v")) != -1) @@ -19,7 +19,7 @@ port = optarg; break; case 'v': - debug = true; + debug = 5; break; default: cout << "Usage: " << argv[0] << " [-p port] [-v(erbose)]" << endl Modified: gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp =================================================================== --- gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp 2008-10-16 05:24:14 UTC (rev 324) +++ gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp 2008-10-16 06:14:30 UTC (rev 325) @@ -10,17 +10,18 @@ #include "trivialtracer.h" #include <iostream> +#include <assert.h> using namespace std; namespace gbxutilacfr { -TrivialTracer::TrivialTracer( bool debug, bool info, bool warn, bool error ) : - debug_(debug), - info_(info), - warn_(warn), - error_(error) +TrivialTracer::TrivialTracer( int debug, int info, int warn, int error ) { + traceLevels_[Tracer::InfoTrace] = info; + traceLevels_[Tracer::WarningTrace] = warn; + traceLevels_[Tracer::ErrorTrace] = error; + traceLevels_[Tracer::DebugTrace] = debug; } void @@ -32,35 +33,36 @@ void TrivialTracer::info( const std::string &message, int level ) { - if ( info_ ) + if ( traceLevels_[Tracer::InfoTrace] >= level ) cout << "info: " << message << endl; } void TrivialTracer::warning( const std::string &message, int level ) { - if ( warn_ ) + if ( traceLevels_[Tracer::WarningTrace] >= level ) cout << "warn: " << message << endl; } void TrivialTracer::error( const std::string &message, int level ) { - if ( error_ ) + if ( traceLevels_[Tracer::ErrorTrace] >= level ) cout << "error: " << message << endl; } void TrivialTracer::debug( const std::string &message, int level ) { - if ( debug_ ) + if ( traceLevels_[Tracer::DebugTrace] >= level ) cout << "debug: " << message << endl; } int TrivialTracer::verbosity( TraceType traceType, DestinationType destType ) const { - return 10; + assert( traceType >= 0 && traceType <= Tracer::NumberOfTraceTypes ); + return traceLevels_[traceType]; } } Modified: gearbox/trunk/src/gbxutilacfr/trivialtracer.h =================================================================== --- gearbox/trunk/src/gbxutilacfr/trivialtracer.h 2008-10-16 05:24:14 UTC (rev 324) +++ gearbox/trunk/src/gbxutilacfr/trivialtracer.h 2008-10-16 06:14:30 UTC (rev 325) @@ -23,8 +23,15 @@ class TrivialTracer : public Tracer { public: - TrivialTracer( bool debug=false, bool info=true, bool warn=true, bool error=true ); + //! + //! Integers specify the tracing level: we'll print out all level at or below this. + //! + TrivialTracer( int debug=0, + int info=9, + int warn=9, + int error=9 ); + virtual void print( const std::string &message ); virtual void info( const std::string &message, int level=1 ); virtual void warning( const std::string &message, int level=1 ); @@ -33,10 +40,8 @@ virtual int verbosity( TraceType traceType, DestinationType destType ) const; private: - bool debug_; - bool info_; - bool warn_; - bool error_; + + int traceLevels_[Tracer::NumberOfTraceTypes]; }; } // namespace This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |