Click here to Skip to main content
15,892,072 members
Articles / Programming Languages / C++

Debug tracing in stream-like way

Rate me:
Please Sign up or sign in to vote.
4.74/5 (19 votes)
24 May 2007CPOL6 min read 86.5K   447   24  
Tracing in the debug window using std::ostream
#include "debug.h"

using namespace GE_;

class myobject
{
private:
	dbg::trackobj<myobject> trk;
};

void function(int n)
{
    dbg::trace trc("function", function);
    trc << "hallo with n = " << n << std::endl;
    if(n) function(n-1);
	else 
	{
		trc << "creating a static object" << std::endl;
		static myobject m3;
	}
}


int main()
{
	dbg::trace trc("main",main);
	function(3);
    trc << "creating two objects on stack" << std::endl;
    myobject m1, m2;
    trc << "Bye" << std::endl;
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Italy Italy
Born and living in Milan (Italy), I'm an engineer in electronics actually working in the ICT department of an important oil/gas & energy company as responsible for planning and engineering of ICT infrastructures.
Interested in programming since the '70s, today I still define architectures for the ICT, deploying dedicated specific client application for engineering purposes, working with C++, MFC, STL, and recently also C# and D.

Comments and Discussions