Examples‎ > ‎

Tracing your code

If you are developing your application, you are going to need to display some informaton when it is executed, in order to debug or diagnose purposes. Then, you must create your own traces and to add them to your code.

To do this, we must create our tracing flag. So, we will be able to turn on and off our tracing information. We add the name and description to the trace static table.

const LPCTSTR szTraceFlags[NUM_TRACE_FLAGS*2] =
{
"system",     "System information",
"ip",         "IP protocol traffic",
"mytrace",    "This is my trace flag",
};

And now, we can use our traces in our code after define our flag.


#define MY_TRACE    2    // The position in the table

TracePrintf(MY_TRACE, "The value of myVar is %d", myVar);



From the console we can turn our traces on using:

trace mytrace

If your detect a critical error in your code, then you can display an error advertisment. You might use "ErrorPrintf" to inform the user of such event. Yo don't need to create any flag to use this function.
Comments