lib/log: passing va_list to user-provided log call
va_list is not passed in logfunc, so the user-provided log call can't get the arguments corresponding to the format string. This patch fixes it and replaces log func pointer in spdk_app_opts with logfunc. Change-Id: I7f7806f47c4fd8f36f3234aa5a8c877db0fc7140 Signed-off-by: Yang Fan <fanyang@smartx.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469828 Reviewed-by: Feng,Li <fengli@smartx.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
3a9b5f3cd2
commit
bb9d17a5c3
@ -135,15 +135,8 @@ struct spdk_app_opts {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* for passing user-provided log call
|
* for passing user-provided log call
|
||||||
*
|
|
||||||
* \param level Log level threshold.
|
|
||||||
* \param file Name of the current source file.
|
|
||||||
* \param line Current source file line.
|
|
||||||
* \param func Current source function name.
|
|
||||||
* \param format Format string to the message.
|
|
||||||
*/
|
*/
|
||||||
void (* log)(int level, const char *file, const int line,
|
logfunc *log;
|
||||||
const char *func, const char *format);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,8 +45,18 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* for passing user-provided log call
|
||||||
|
*
|
||||||
|
* \param level Log level threshold.
|
||||||
|
* \param file Name of the current source file.
|
||||||
|
* \param line Current source file line.
|
||||||
|
* \param func Current source function name.
|
||||||
|
* \param format Format string to the message.
|
||||||
|
* \param args Additional arguments for format string.
|
||||||
|
*/
|
||||||
typedef void logfunc(int level, const char *file, const int line,
|
typedef void logfunc(int level, const char *file, const int line,
|
||||||
const char *func, const char *format);
|
const char *func, const char *format, va_list args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the logging module. Messages prior
|
* Initialize the logging module. Messages prior
|
||||||
|
@ -117,7 +117,9 @@ spdk_log(enum spdk_log_level level, const char *file, const int line, const char
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (g_log) {
|
if (g_log) {
|
||||||
g_log(level, file, line, func, format);
|
va_start(ap, format);
|
||||||
|
g_log(level, file, line, func, format, ap);
|
||||||
|
va_end(ap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user