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: Huiming Xie <xiehuiming@huawei.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462790 Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
c0d4f7145e
commit
a50246fb64
@ -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);
|
||||
@ -152,7 +157,6 @@ spdk_log(enum spdk_log_level level, const char *file, const int line, const char
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user