Different Kinds of Messages

Top  Previous  Next

Here's a simple example showing different kinds of messages.  You will find this demo project in the DebugLibrary source code directory, along with project files for ms .net2003,vc6, and dev-c++.

 

//---------------------------------------------------------------------------

// System includes

#include <iostream>

#include <exception>

#include <stdexcept>

//---------------------------------------------------------------------------

 

//---------------------------------------------------------------------------

// Include the Debugging Library file (only our main should include this

//  file, additional .cpp files should include "jrdebug.h"

//  alternatively, you could add this cpp to your project or makefile.

#include "../../jrdebug_main.cpp"

//---------------------------------------------------------------------------

 

//---------------------------------------------------------------------------

int main(int argc, char *argv[])

{

 int count;

 int max=20;

 debugout << "Starting strees test of messages.";

 

 // loop

 for (count=1;count<=max;++count)

         dbprintf(JrdMessage,"test #%d of %d",count,max);

 for (count=1;count<=max;++count)

         dbprintf(JrdWarning,"test #%d of %d",count,max);

 for (count=1;count<=max;++count)

         dbprintf(JrdError,"test #%d of %d",count,max);

 for (count=1;count<=max;++count)

         dbprintf(JrdNote,"test #%d of %d",count,max);

 for (count=1;count<=max;++count)

         dbprintf(JrdTest,"test #%d of %d",count,max);

 for (count=1;count<=max;++count)

         dbprintf(JrdCustom,"test #%d of %d",count,max);

 

 // enable some stuff

 JrDebug::EnableExceptionLogging();

 JrDebug::SetDisplayPassingAsserts(true);

         

 // only one alarm

 dbprintf(JrdAlarm,"alarm single test");

 // an assert

 dbassert(count<1000);

 // an exception

 try

         {

         dbthrow(std::exception("jr exception"),"");

         }

 catch (...)

         {

         }

 

 

 // done

 debugout << "Ending stress test of messages.";

 

 // return success

 std::cout << "Program has finished; if you were running the debug monitor you should have seen 2 messages."<<std::endl;

 return 0;

}

//---------------------------------------------------------------------------