Sfoglia il codice sorgente

LOG4C_HEX_DUMP函数Bug修复:参数固定。

Jeff 6 anni fa
parent
commit
7455a66eb4

+ 16 - 15
log4cproj_c/Log4C/log.c

@@ -391,19 +391,19 @@ void log_msg_no_file_num(const char *strCatName, const int iPriority, const char
 	}
 }
 
-
-/** 日志记录,不记录文件名和行号,没有任何layout转换,直接输出相应的字符文本到日志中
-此条记录没有行号,也没有线程号,也没有回车等
-日志记录为一个字符串指针指向的内容
-@return void
-作者:jesse  日期:2008-9-14
-*/
-void log_msg_no_file_num_no_layout(
-								   const char *strCatName,	///category名
-								   const int iPriority,		///日志记录级别
-								   const char *strFormat,		///日志内容格式
-								   ...						///日志内容
-								   )
+/************************************************************************/
+/*  函数:[3/30/2019 Wang];
+/*  描述:日志记录,不记录文件名和行号,没有任何layout转换,直接输出相应的字符文本到日志中;
+/*  此条记录没有行号,也没有线程号,也没有回车等
+/*  日志记录为一个字符串指针指向的内容
+/*  参数:;
+/*  	[IN] strCatName:category名;
+/*  	[IN] iPriority:日志记录级别;
+/*  	[IN] strFormat:日志内容格式;
+/*  	[IN] ...:日志内容;
+/*  返回:void;
+/************************************************************************/
+void log_msg_no_file_num_no_layout(const char *strCatName, const int iPriority, const char *strFormat, ...)
 {
 	const log4c_category_t* a_category = log4c_category_get(strCatName);
 	if (log4c_category_is_priority_enabled(a_category, iPriority)) 
@@ -557,17 +557,18 @@ const LOG_PARAM  log_condition_vsnprintf_wrapper(
 /*  描述:;
 /*  参数:;
 /*  	[IN] iPriority:日志记录级别;
+/*  	[IN] strFormat:日志内容格式;
 /*  	[IN] strHexBuf:缓冲区首地址;
 /*  	[IN] iHexBufLen:缓冲区长度;
 /*  	[IN] ...:日志内容;
 /*  返回:void;
 /************************************************************************/
-void log_hex_dump_vsnprintf_wrapper(const int iPriority, const char* strHexBuf, const int iHexBufLen, ...)
+void log_hex_dump_vsnprintf_wrapper(const int iPriority, const char* strFormat, const char* strHexBuf, const int iHexBufLen)
 {
 	char *strBuffer = (char *)malloc(LOG4C_BUFFER_SIZE_MAX);
 	memset(strBuffer, 0, LOG4C_BUFFER_SIZE_MAX);
 	log4c_sprintf_data((char*)(strHexBuf), (iHexBufLen), strBuffer);
-	log_msg_no_file_num(DEFAULT_LOG_CATEGORY_NAME, iPriority, strBuffer ); 
+	log_msg_no_file_num(DEFAULT_LOG_CATEGORY_NAME, iPriority, strFormat, strBuffer ); 
 }
 
 /************************************************************************/

+ 1 - 0
log4cproj_c/Log4C/log4c/log.h

@@ -331,6 +331,7 @@ LOG4C_API const LOG_PARAM  log_condition_vsnprintf_wrapper(
 
 LOG4C_API void log_hex_dump_vsnprintf_wrapper(
 	const int iPriority,	///日志记录级别
+	const char* strFormat,  ///日志内容格式
 	const char* strHexBuf,	///缓冲区首地址
 	const int iHexBufLen,	///缓冲区长度
 	...						///日志内容

+ 1 - 1
log4cproj_c/testlog4c/testlog4c.cpp

@@ -64,7 +64,7 @@ int _tmain(int argc, _TCHAR* argv[])
 	LOG4C_BLOCK_END(("LOG4C_BLOCK_BEGIN0"));
 
 	char strBuffer[128] = "You are the Best One!\0 Yes.";
-	LOG4C_HEX_DUMP((LOG_INFO, strBuffer, sizeof(strBuffer)));
+	LOG4C_HEX_DUMP((LOG_INFO, "%s", strBuffer, sizeof(strBuffer)));
 
 
 	LOG4C_ORIGIN ((LOG_ERROR,"LOG4C_ORIGIN"));