The functions provied allow you to print formatted and unformatted debugging messages alongwith their line numbers.
//Log the entry and exit of a function, along with the file name and line number.
//Call 'dbgTraceIn()' at the start of the function and 'dbgTraceOut()' at the end of the function.
void function()
{
dbgTraceIn();
//Do something here.
dbgTraceOut();
}
//Call 'dbgMsg()' and pass in the message as a string.
//Newlines are added automatically at the end of the string, so there is no need to do it yourself.
void function()
{
dbgTraceIn();
dbgMsg("Inside function 'function'");
dbgTraceOut();
}
//Call 'dbgFmtMsg()'.
//The first argument is the format string. Formatting rules of 'printf()' apply.
//The next arguments are the variables that have to be printed in the specific format.
//Newlines are added automatically at the end, so there is no need to do it yourself.
//Call this macro just like you would call 'printf()'.
void function()
{
dbgTraceIn();
dbgMsg("Inside function 'function'");
int a=10,b=12;
dbgFmtMsg("[%d] + [%d] = [%d]",a,b,a+b);
dbgTraceOut();
}
[TRACE]>[ 6]_main.c::main():
[TRACE]>[ 14]_|___test.c::add():
[DEBUG]:[ 15]_|___|___Adding 23 and 45.
[DEBUG]:[ 16]_|___|___Sum is [68].
[TRACE]>[ 6]_|___|___test.c::sub():
[DEBUG]:[ 7]_|___|___|___Subtracting 23 and 45.
[DEBUG]:[ 8]_|___|___|___Difference is [-22].
[TRACE]<[ 9]_|___|___test.c::sub():
[TRACE]<[ 18]_|___test.c::add():
[TRACE]<[ 8]_main.c::main():
The number seen inside the '[' and ']' at the left is the line number of the corresponding file from which the message was printed.
<file_name>::<function_name>()