Commit a50246fb authored by x00267701's avatar x00267701 Committed by Changpeng Liu
Browse files

log: optimize spdk_log() when logging is disabled



If the log level of the output log is higher than
the process's log level, the system does not output
it, so we needn't generate the formatting logs.

Change-Id: I36be0e6807ed575fcbf1d0ae01f064a6ca2c4539
Signed-off-by: default avatarHuiming Xie <xiehuiming@huawei.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462790


Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent c0d4f714
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -116,6 +116,15 @@ spdk_log(enum spdk_log_level level, const char *file, const int line, const char
	char buf[MAX_TMPBUF];
	va_list ap;

	if (g_log) {
		g_log(level, file, line, func, format);
		return;
	}

	if (level > g_spdk_log_print_level && level > g_spdk_log_level) {
		return;
	}

	switch (level) {
	case SPDK_LOG_ERROR:
		severity = LOG_ERR;
@@ -134,10 +143,6 @@ spdk_log(enum spdk_log_level level, const char *file, const int line, const char
		return;
	}

	if (g_log) {
		g_log(level, file, line, func, format);

	} else {
	va_start(ap, format);

	vsnprintf(buf, sizeof(buf), format, ap);
@@ -153,7 +158,6 @@ spdk_log(enum spdk_log_level level, const char *file, const int line, const char

	va_end(ap);
}
}

static void
fdump(FILE *fp, const char *label, const uint8_t *buf, size_t len)