var_list 格式化输出,Windows 和Linux

Linux:

void CServerlog::WriteFormatDebugLog(char* lpFormat, ...)
{
    const DWORD BufSize = 1024;
    char szBuffer[BufSize];

    va_list args;     //格式化消息

    va_start(args, lpFormat);
    vsprintf(szBuffer,  lpFormat, args);     //vsprintf_s BufSize - strlen(szMsg),
    va_end(args);
    LOG4CXX_DEBUG(infologger,szBuffer);
}

VC下:

void CServerlog::WriteFormatInfoLog(LPCSTR lpFormat, ...)
{
	const DWORD BufSize = 1024;
	char szMsg[BufSize];

	va_list args; 	//格式化消息

	va_start(args, lpFormat);    
	wvsprintfA(szMsg,  lpFormat, args);	 //vsprintf_s BufSize - strlen(szMsg),
	va_end(args);  
	//输出信息
	LOG4CXX_INFO(infologger,szMsg);
}


猜你喜欢

转载自blog.csdn.net/qq_28016947/article/details/51015177