Debug / Logging Class

aon_debug.h
aon_debug.cpp

PROBLEM: So, you want to add debugging and logging output through your C++ program, using streams, but you don't want to waste CPU cycles if the logging is turned off or reduced for production systems.

SOLUTION: Create a dummy streambuffer class which we can use as a sink for unwanted data coming into our stream (think /dev/null). Then create a class that returns either clog or the dummy stream depending on the debug level.

The idea and some of the code came from this usenet post.

Usage:

Really Simple!

By including aon_debug.h, you have access to the "dout" instance of the Debug class. You use it just like cout, with a modifier for level


   dout.setLevel(ALL);  // print all levels of output

   dout(INFO) << "This is some information I wish to log\n";
	

   dout.setLevel(RELEASE);
	
   dout(ERR) << This error will be printed since it is important\n";
   dout(INFO) << "This info was meant just for the developer and "
              << "will not be printed at this debug level" << endl;