Archive for September, 2011

log function in C using variable arguments…

void Log(TCHAR *szFmter, …)
{
if(NULL !=  pfLog)
{
wchar_t szBuff[MAX_LOG_BUFF_SIZE];

SYSTEMTIME  t;
GetLocalTime( &t);

_stprintf_s(szTime, _countof(szTime), _T(“%02d.%02d.%hd.%02d.%02d.%02d.%003d”), t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond, t.wMilliseconds);
va_list args;
va_start( args, szFmter);
vswprintf_s(szBuff, szFmter, args );
va_end(args);

//writing the values in the log file
_fwprintf_p(pfLog, _T(“%s#%s\n”), szTime, szBuff);
fflush(pfLog);
}
}

Advertisements

Leave a Comment