#define MAX_LOG_FILE_SIZEstatic_cast<int>(1024*1024/2)
#ifdef _DEBUG
intg_iDebugLevel=DBG_VERBOSE;
#else
intg_iDebugLevel=DBG_ERROR;
#endif
boolg_bSaveLogFile=false;
TCHARg_bLogSavePath[MAX_PATH] = _T("C:\\log");
staticTCHARs_szLogFile[MAX_PATH] = {0};
staticbools_bLogPathInit = false;
#if defined(DBG_THREADSAFE)
staticOS_CLockables_mtxEntry;
#endif
BOOL DbgPrint(__in LPCTSTR lpszFormatString, ...)
{
BOOL bResult = TRUE;
va_list VAList;
va_start(VAList, lpszFormatString);
if (g_bSaveLogFile)
{
#if defined(DBG_THREADSAFE)
OS_CAutoLock lock(s_mtxEntry);
#endif
if (!s_bLogPathInit)
{
SYSTEMTIME stime = {0};
GetLocalTime(&stime);
#if defined(UNDER_CE)
_stprintf(s_szLogFile, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#else
_stprintf_s(s_szLogFile, MAX_PATH, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#endif
s_bLogPathInit = true;
}
FILE* pFile = _tfopen(s_szLogFile, _T("a"));
if (pFile != NULL)
{
fseek(pFile,SEEK_END,0);
long cbSize = ftell(pFile);
if (cbSize > MAX_LOG_FILE_SIZE)
{
fclose(pFile);
{
SYSTEMTIME stime = {0};
GetLocalTime(&stime);
#if defined(UNDER_CE)
_stprintf(s_szLogFile, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#else
_stprintf_s(s_szLogFile, MAX_PATH, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#endif
s_bLogPathInit = true;
}
pFile = _tfopen(s_szLogFile, _T("a"));
if (pFile == NULL)
{
return FALSE;
}
}
_vftprintf(pFile, lpszFormatString, VAList);
fflush(pFile);
fclose(pFile);
pFile = NULL;
}
}
else
{
#if defined(UNDER_CE)
_vtprintf(lpszFormatString, VAList);
#else
TCHAR szBuf[MAX_PATH * 2] = {0};
_vstprintf_s(szBuf, MAX_PATH, lpszFormatString, VAList);
OutputDebugString(szBuf);
#endif
}
va_end(VAList);
return bResult;
}
请高人指点
追答起码说一下这是干嘛的程序吧