Wednesday, April 25, 2007

LOG for logging error in DebugString

This function is like a sprintf(), we can format the strings and display the error in

Debug String...


Usage :

_LOG(str,"Error code is : %2x",hr);


the above fn displays the error in Debug String as follows...
Example
Error code is : 0x80004566




void _LOG(LPCSTR szFormat, ...)
{
char szMessage[2048];
va_list Args;

va_start(Args, szFormat);
int result=_vsnprintf(szMessage,2048, szFormat, Args);
va_end(Args);
if(result==-1)
{
OutputDebugString("DebugString too long, truncated!!\n");
}
OutputDebugString(szMessage);
}

Labels:

0 Comments:

Post a Comment

<< Home