log: dynamically generate usage for -t option

Change-Id: I8c709b507c4cb00092d5dc9b1e8ca1c0fe880b02
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-08-22 09:15:35 -07:00
parent 32a046d7b8
commit 20bee521a6
4 changed files with 24 additions and 10 deletions

View File

@ -92,11 +92,7 @@ usage(char *executable_name)
printf(" -n channel number of memory channels used for DPDK\n"); printf(" -n channel number of memory channels used for DPDK\n");
printf(" -p core master (primary) core for DPDK\n"); printf(" -p core master (primary) core for DPDK\n");
printf(" -s size memory size in MB for DPDK\n"); printf(" -s size memory size in MB for DPDK\n");
#ifdef DEBUG spdk_tracelog_usage(stdout, "-t");
printf(" -t flag trace flag (all, net, iscsi, scsi, target, debug)\n");
#else
printf(" -t flag trace flag (not supported - must rebuild with CONFIG_DEBUG=y)\n");
#endif
printf(" -v verbose (enable warnings)\n"); printf(" -v verbose (enable warnings)\n");
printf(" -H show this usage\n"); printf(" -H show this usage\n");
printf(" -V show version\n"); printf(" -V show version\n");

View File

@ -104,11 +104,8 @@ usage(void)
printf(" -p core master (primary) core for DPDK\n"); printf(" -p core master (primary) core for DPDK\n");
printf(" -s size memory size in MB for DPDK\n"); printf(" -s size memory size in MB for DPDK\n");
#ifdef DEBUG spdk_tracelog_usage(stdout, "-t");
printf(" -t flag - trace flag options (all, rdma, nvmf, debug)\n");
#else
printf(" -t flag - trace flag options (not supported - must rebuild with CONFIG_DEBUG=y)\n");
#endif
printf(" -v - verbose (enable warnings)\n"); printf(" -v - verbose (enable warnings)\n");
printf(" -H - show this usage\n"); printf(" -H - show this usage\n");
printf(" -d - disable coredump file enabling\n"); printf(" -d - disable coredump file enabling\n");

View File

@ -111,4 +111,6 @@ const char *spdk_log_get_trace_flag_name(size_t idx);
void spdk_open_log(void); void spdk_open_log(void);
void spdk_close_log(void); void spdk_close_log(void);
void spdk_tracelog_usage(FILE *f, const char *trace_arg);
#endif /* SPDK_LOG_H */ #endif /* SPDK_LOG_H */

View File

@ -375,3 +375,22 @@ spdk_close_log(void)
{ {
closelog(); closelog();
} }
void
spdk_tracelog_usage(FILE *f, const char *trace_arg)
{
#ifdef DEBUG
size_t i;
fprintf(f, " %s flag enable trace flag (all", trace_arg);
for (i = 0; i < g_num_trace_flags; i++) {
fprintf(f, ", %s", g_trace_flags[i].name);
}
fprintf(f, ")\n");
#else
fprintf(f, " %s flag enable trace flag (not supported - must rebuild with CONFIG_DEBUG=y)\n",
trace_arg);
#endif
}