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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: