event/app: allow to enable log flag for release builds

Log flags could also report on SPDK_LOG_INFO level by using
SPDK_INFOLOG() macro. Yet this did not result in additional
log due to check for debug build.

This patch allows release builds to use that flag.
Meanwhile the -L option besides turning on particular log flag
changes print log level to SPDK_LOG_DEBUG.

Applied changes to serveral applications to follow the
behaviour of event framework.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ib0d6cce33263c350d6d83300d60e7d15bdfe4b64
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4557
Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-10-07 10:53:50 -04:00
parent 779a6bdf82
commit 8a76c2484a
9 changed files with 15 additions and 41 deletions

View File

@ -26,6 +26,10 @@ A log flag structure, `spdk_log_register_flag`, `spdk_log_get_first_flag`,
enable registering and interacting with log flags. Added `SPDK_INFOLOG`, `SPDK_DEBUGLOG` enable registering and interacting with log flags. Added `SPDK_INFOLOG`, `SPDK_DEBUGLOG`
and `SPDK_LOGDUMP` macros to display logs for specified log flag. and `SPDK_LOGDUMP` macros to display logs for specified log flag.
The log flags in the event framework `-L` and several SPDK applications has been enabled on
release builds of SPDK. On debug builds this option will additionally set
log print level to `SPDK_LOG_DEBUG`.
### ocf ### ocf
Updated OCF submodule to v20.03.1 Updated OCF submodule to v20.03.1

View File

@ -45,7 +45,7 @@ Param | Long Param | Type | Default | Descript
-W | --pci-whitelist | B:D:F | | @ref cmd_arg_pci_blacklist_whitelist. -W | --pci-whitelist | B:D:F | | @ref cmd_arg_pci_blacklist_whitelist.
-R | --huge-unlink | flag | | @ref cmd_arg_huge_unlink -R | --huge-unlink | flag | | @ref cmd_arg_huge_unlink
| | --huge-dir | string | the first discovered | allocate hugepages from a specific mount | | --huge-dir | string | the first discovered | allocate hugepages from a specific mount
-L | --logflag | string | | @ref cmd_arg_debug_log_flags -L | --logflag | string | | @ref cmd_arg_log_flags
### Configuration file {#cmd_arg_config_file} ### Configuration file {#cmd_arg_config_file}
@ -137,11 +137,11 @@ By default, each DPDK-based application tries to remove any orphaned hugetlbfs
files during its initialization. This option removes hugetlbfs files of the current files during its initialization. This option removes hugetlbfs files of the current
process as soon as they're created, but is not compatible with `--shm-id`. process as soon as they're created, but is not compatible with `--shm-id`.
### Debug log {#cmd_arg_debug_log_flags} ### Log flag {#cmd_arg_log_flags}
Enable a specific debug log type. This option can be used more than once. A list of Enable a specific log type. This option can be used more than once. A list of
all available types is provided in the `--help` output, with `--logflag all` all available types is provided in the `--help` output, with `--logflag all`
enabling all of them. Debug logs are only available in debug builds of SPDK. enabling all of them. Additionally enables debug print level in debug builds of SPDK.
## CPU mask {#cpu_mask} ## CPU mask {#cpu_mask}

View File

@ -711,12 +711,8 @@ parse_args(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG); spdk_log_set_print_level(SPDK_LOG_DEBUG);
#ifndef DEBUG
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -T flag.\n",
argv[0]);
usage(argv[0]);
return 0;
#endif #endif
break; break;
default: default:

View File

@ -1830,12 +1830,8 @@ parse_args(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG); spdk_log_set_print_level(SPDK_LOG_DEBUG);
#ifndef DEBUG
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -L flag.\n",
argv[0]);
usage(argv[0]);
return 0;
#endif #endif
break; break;
case 'H': case 'H':

View File

@ -1936,12 +1936,8 @@ parse_args(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG); spdk_log_set_print_level(SPDK_LOG_DEBUG);
#ifndef DEBUG
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -T flag.\n",
argv[0]);
usage(argv[0]);
return 0;
#endif #endif
break; break;
case 'V': case 'V':

View File

@ -761,12 +761,8 @@ parse_args(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG); spdk_log_set_print_level(SPDK_LOG_DEBUG);
#ifndef DEBUG
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -T flag.\n",
argv[0]);
usage(argv[0]);
return 0;
#endif #endif
break; break;
default: default:

View File

@ -964,18 +964,13 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts,
} }
break; break;
case LOGFLAG_OPT_IDX: case LOGFLAG_OPT_IDX:
#ifndef DEBUG
SPDK_ERRLOG("%s must be configured with --enable-debug for -L flag\n",
argv[0]);
usage(app_usage);
goto out;
#else
rc = spdk_log_set_flag(optarg); rc = spdk_log_set_flag(optarg);
if (rc < 0) { if (rc < 0) {
SPDK_ERRLOG("unknown flag\n"); SPDK_ERRLOG("unknown flag\n");
usage(app_usage); usage(app_usage);
goto out; goto out;
} }
#ifdef DEBUG
opts->print_level = SPDK_LOG_DEBUG; opts->print_level = SPDK_LOG_DEBUG;
break; break;
#endif #endif

View File

@ -172,17 +172,12 @@ spdk_log_get_next_flag(struct spdk_log_flag *flag)
void void
spdk_log_usage(FILE *f, const char *log_arg) spdk_log_usage(FILE *f, const char *log_arg)
{ {
#ifdef DEBUG
struct spdk_log_flag *flag; struct spdk_log_flag *flag;
fprintf(f, " %s, --logflag <flag> enable debug log flag (all", log_arg); fprintf(f, " %s, --logflag <flag> enable log flag (all", log_arg);
TAILQ_FOREACH(flag, &g_log_flags, tailq) { TAILQ_FOREACH(flag, &g_log_flags, tailq) {
fprintf(f, ", %s", flag->name); fprintf(f, ", %s", flag->name);
} }
fprintf(f, ")\n"); fprintf(f, ")\n");
#else
fprintf(f, " %s, --logflag <flag> enable debug log flag (not supported"
" - must reconfigure with --enable-debug)\n", log_arg);
#endif
} }

View File

@ -337,12 +337,8 @@ parse_args(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG); spdk_log_set_print_level(SPDK_LOG_DEBUG);
#ifndef DEBUG
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -L flag.\n",
argv[0]);
usage(argv[0]);
return 0;
#endif #endif
break; break;
case 'T': case 'T':