Commit bb9d17a5 authored by fanyang's avatar fanyang Committed by Jim Harris
Browse files

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: default avatarYang Fan <fanyang@smartx.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469828


Reviewed-by: default avatarFeng,Li <fengli@smartx.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 3a9b5f3c
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -135,15 +135,8 @@ struct spdk_app_opts {

	/**
	 * 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,
		     const char *func, const char *format);
	logfunc         *log;

};

+11 −1
Original line number Diff line number Diff line
@@ -45,8 +45,18 @@
extern "C" {
#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,
		     const char *func, const char *format);
		     const char *func, const char *format, va_list args);

/**
 * Initialize the logging module. Messages prior
+3 −1
Original line number Diff line number Diff line
@@ -117,7 +117,9 @@ spdk_log(enum spdk_log_level level, const char *file, const int line, const char
	va_list ap;

	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;
	}