From b4b7d5d3ff81ef83c2079274a008c5cd2896a6b2 Mon Sep 17 00:00:00 2001
From: Jim Harris <james.r.harris@intel.com>
Date: Mon, 26 Nov 2018 23:57:58 -0700
Subject: [PATCH] log: remove "trace" from public API

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I90e7d698cae7577736319e38f089e3b759c9beef

Reviewed-on: https://review.gerrithub.io/435343
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
---
 examples/blob/cli/blobcli.c       |  4 ++--
 examples/nvme/identify/identify.c |  4 ++--
 examples/nvme/reserve/reserve.c   |  2 +-
 include/spdk/log.h                | 32 +++++++++++++++----------------
 include/spdk_internal/log.h       |  2 +-
 lib/event/app.c                   |  4 ++--
 lib/log/log.c                     |  2 +-
 lib/log/log_flags.c               | 26 ++++++++++++-------------
 lib/log/rpc/log_rpc.c             |  4 ++--
 test/nvme/aer/aer.c               |  4 ++--
 test/unit/lib/log/log.c/log_ut.c  | 14 +++++++-------
 11 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/examples/blob/cli/blobcli.c b/examples/blob/cli/blobcli.c
index e0b843a8b5..342475645c 100644
--- a/examples/blob/cli/blobcli.c
+++ b/examples/blob/cli/blobcli.c
@@ -408,7 +408,7 @@ show_bs_cb(void *arg1, spdk_blob_id blobid, int bserrno)
 	printf("\t# free clusters: %" PRIu64 "\n", val);
 
 	bstype = spdk_bs_get_bstype(cli_context->bs);
-	spdk_trace_dump(stdout, "\tblobstore type:", &bstype, sizeof(bstype));
+	spdk_log_dump(stdout, "\tblobstore type:", &bstype, sizeof(bstype));
 
 	/*
 	 * Private info isn't accessible via the public API but
@@ -466,7 +466,7 @@ show_blob(struct cli_context_t *cli_context)
 		printf("\n(%d) Name:%s\n", i,
 		       spdk_xattr_names_get_name(names, i));
 		printf("(%d) Value:\n", i);
-		spdk_trace_dump(stdout, "", value, value_len);
+		spdk_log_dump(stdout, "", value, value_len);
 	}
 
 	/*
diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c
index 3958483b08..9cfe47d4f6 100644
--- a/examples/nvme/identify/identify.c
+++ b/examples/nvme/identify/identify.c
@@ -1588,7 +1588,7 @@ usage(const char *program_name)
 	printf("     subnqn      Subsystem NQN (default: %s)\n", SPDK_NVMF_DISCOVERY_NQN);
 	printf("    Example: -r 'trtype:RDMA adrfam:IPv4 traddr:192.168.100.8 trsvcid:4420'\n");
 
-	spdk_tracelog_usage(stdout, "-L");
+	spdk_log_usage(stdout, "-L");
 
 	printf(" -i         shared memory group ID\n");
 	printf(" -p         core number in decimal to run this application which started from 0\n");
@@ -1632,7 +1632,7 @@ parse_args(int argc, char **argv)
 			g_hex_dump = true;
 			break;
 		case 'L':
-			rc = spdk_log_set_trace_flag(optarg);
+			rc = spdk_log_set_flag(optarg);
 			if (rc < 0) {
 				fprintf(stderr, "unknown flag\n");
 				usage(argv[0]);
diff --git a/examples/nvme/reserve/reserve.c b/examples/nvme/reserve/reserve.c
index b632039876..63bdbcfe71 100644
--- a/examples/nvme/reserve/reserve.c
+++ b/examples/nvme/reserve/reserve.c
@@ -109,7 +109,7 @@ get_host_identifier(struct spdk_nvme_ctrlr *ctrlr)
 	}
 
 	if (get_host_id_successful) {
-		spdk_trace_dump(stdout, "Get Feature: Host Identifier:", host_id, host_id_size);
+		spdk_log_dump(stdout, "Get Feature: Host Identifier:", host_id, host_id_size);
 	}
 
 	return 0;
diff --git a/include/spdk/log.h b/include/spdk/log.h
index b6f0dd62c4..5d47299bfa 100644
--- a/include/spdk/log.h
+++ b/include/spdk/log.h
@@ -140,47 +140,47 @@ void spdk_log(enum spdk_log_level level, const char *file, const int line, const
 	      const char *format, ...) __attribute__((__format__(__printf__, 5, 6)));
 
 /**
- * Dump the trace to a file.
+ * Log the contents of a raw buffer to a file.
  *
- * \param fp File to hold the trace.
+ * \param fp File to hold the log.
  * \param label Label to print to the file.
- * \param buf Buffer that holds the trace information.
- * \param len Length of trace to dump.
+ * \param buf Buffer that holds the log information.
+ * \param len Length of buffer to dump.
  */
-void spdk_trace_dump(FILE *fp, const char *label, const void *buf, size_t len);
+void spdk_log_dump(FILE *fp, const char *label, const void *buf, size_t len);
 
 /**
- * Check whether the trace flag exists and is enabled.
+ * Check whether the log flag exists and is enabled.
  *
  * \return true if enabled, or false otherwise.
  */
-bool spdk_log_get_trace_flag(const char *flag);
+bool spdk_log_get_flag(const char *flag);
 
 /**
- * Enable the trace flag.
+ * Enable the log flag.
  *
- * \param flag Trace flag to be enabled.
+ * \param flag Log flag to be enabled.
  *
  * \return 0 on success, -1 on failure.
  */
-int spdk_log_set_trace_flag(const char *flag);
+int spdk_log_set_flag(const char *flag);
 
 /**
- * Clear a trace flag.
+ * Clear a log flag.
  *
- * \param flag Trace flag to clear.
+ * \param flag Log flag to clear.
  *
  * \return 0 on success, -1 on failure.
  */
-int spdk_log_clear_trace_flag(const char *flag);
+int spdk_log_clear_flag(const char *flag);
 
 /**
- * Show all the log trace flags and their usage.
+ * Show all the log flags and their usage.
  *
  * \param f File to hold all the flags' information.
- * \param trace_arg Command line option to set/enable the trace flag.
+ * \param log_arg Command line option to set/enable the log flag.
  */
-void spdk_tracelog_usage(FILE *f, const char *trace_arg);
+void spdk_log_usage(FILE *f, const char *log_arg);
 
 #ifdef __cplusplus
 }
diff --git a/include/spdk_internal/log.h b/include/spdk_internal/log.h
index 695a293af6..5ec5645fe9 100644
--- a/include/spdk_internal/log.h
+++ b/include/spdk_internal/log.h
@@ -89,7 +89,7 @@ __attribute__((constructor)) static void register_trace_flag_##flag(void) \
 	do {										\
 		extern struct spdk_log_flag FLAG;					\
 		if ((FLAG.enabled) && (LEN)) {						\
-			spdk_trace_dump(stderr, (LABEL), (BUF), (LEN));			\
+			spdk_log_dump(stderr, (LABEL), (BUF), (LEN));			\
 		}									\
 	} while (0)
 
diff --git a/lib/event/app.c b/lib/event/app.c
index a9fd926407..feda6f3926 100644
--- a/lib/event/app.c
+++ b/lib/event/app.c
@@ -739,7 +739,7 @@ usage(void (*app_usage)(void))
 	printf("      --huge-dir <path>    use a specific hugetlbfs mount to reserve memory from\n");
 	printf("      --num-trace-entries <num>   number of trace entries for each core (default %d)\n",
 	       SPDK_APP_DEFAULT_NUM_TRACE_ENTRIES);
-	spdk_tracelog_usage(stdout, "-L");
+	spdk_log_usage(stdout, "-L");
 	spdk_trace_mask_usage(stdout, "-e");
 	if (app_usage) {
 		app_usage();
@@ -903,7 +903,7 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts,
 			usage(app_usage);
 			goto out;
 #else
-			rc = spdk_log_set_trace_flag(optarg);
+			rc = spdk_log_set_flag(optarg);
 			if (rc < 0) {
 				fprintf(stderr, "unknown flag\n");
 				usage(app_usage);
diff --git a/lib/log/log.c b/lib/log/log.c
index 9f4546ce7e..fe40e8ea87 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -183,7 +183,7 @@ fdump(FILE *fp, const char *label, const uint8_t *buf, size_t len)
 }
 
 void
-spdk_trace_dump(FILE *fp, const char *label, const void *buf, size_t len)
+spdk_log_dump(FILE *fp, const char *label, const void *buf, size_t len)
 {
 	fdump(fp, label, buf, len);
 }
diff --git a/lib/log/log_flags.c b/lib/log/log_flags.c
index bce6103891..572ad5fe7b 100644
--- a/lib/log/log_flags.c
+++ b/lib/log/log_flags.c
@@ -85,7 +85,7 @@ spdk_log_get_backtrace_level(void) {
 }
 
 static struct spdk_log_flag *
-get_trace_flag(const char *name)
+get_log_flag(const char *name)
 {
 	struct spdk_log_flag *flag;
 
@@ -109,7 +109,7 @@ spdk_log_register_trace_flag(const char *name, struct spdk_log_flag *flag)
 		return;
 	}
 
-	if (get_trace_flag(name)) {
+	if (get_log_flag(name)) {
 		SPDK_ERRLOG("duplicate spdk_log_flag '%s'\n", name);
 		assert(false);
 		return;
@@ -126,9 +126,9 @@ spdk_log_register_trace_flag(const char *name, struct spdk_log_flag *flag)
 }
 
 bool
-spdk_log_get_trace_flag(const char *name)
+spdk_log_get_flag(const char *name)
 {
-	struct spdk_log_flag *flag = get_trace_flag(name);
+	struct spdk_log_flag *flag = get_log_flag(name);
 
 	if (flag && flag->enabled) {
 		return true;
@@ -138,7 +138,7 @@ spdk_log_get_trace_flag(const char *name)
 }
 
 static int
-set_trace_flag(const char *name, bool value)
+set_log_flag(const char *name, bool value)
 {
 	struct spdk_log_flag *flag;
 
@@ -149,7 +149,7 @@ set_trace_flag(const char *name, bool value)
 		return 0;
 	}
 
-	flag = get_trace_flag(name);
+	flag = get_log_flag(name);
 	if (flag == NULL) {
 		return -1;
 	}
@@ -160,15 +160,15 @@ set_trace_flag(const char *name, bool value)
 }
 
 int
-spdk_log_set_trace_flag(const char *name)
+spdk_log_set_flag(const char *name)
 {
-	return set_trace_flag(name, true);
+	return set_log_flag(name, true);
 }
 
 int
-spdk_log_clear_trace_flag(const char *name)
+spdk_log_clear_flag(const char *name)
 {
-	return set_trace_flag(name, false);
+	return set_log_flag(name, false);
 }
 
 struct spdk_log_flag *
@@ -184,11 +184,11 @@ spdk_log_get_next_trace_flag(struct spdk_log_flag *flag)
 }
 
 void
-spdk_tracelog_usage(FILE *f, const char *trace_arg)
+spdk_log_usage(FILE *f, const char *log_arg)
 {
 #ifdef DEBUG
 	struct spdk_log_flag *flag;
-	fprintf(f, " %s, --traceflag <flag>    enable debug log flag (all", trace_arg);
+	fprintf(f, " %s, --traceflag <flag>    enable debug log flag (all", log_arg);
 
 	TAILQ_FOREACH(flag, &g_trace_flags, tailq) {
 		fprintf(f, ", %s", flag->name);
@@ -197,6 +197,6 @@ spdk_tracelog_usage(FILE *f, const char *trace_arg)
 	fprintf(f, ")\n");
 #else
 	fprintf(f, " %s, --traceflag <flag>    enable debug log flag (not supported"
-		" - must rebuild with --enable-debug)\n", trace_arg);
+		" - must rebuild with --enable-debug)\n", log_arg);
 #endif
 }
diff --git a/lib/log/rpc/log_rpc.c b/lib/log/rpc/log_rpc.c
index 5d35280cc8..dc53ef2871 100644
--- a/lib/log/rpc/log_rpc.c
+++ b/lib/log/rpc/log_rpc.c
@@ -261,7 +261,7 @@ spdk_rpc_set_trace_flag(struct spdk_jsonrpc_request *request,
 		goto invalid;
 	}
 
-	spdk_log_set_trace_flag(req.flag);
+	spdk_log_set_flag(req.flag);
 	free_rpc_trace_flag(&req);
 
 	w = spdk_jsonrpc_begin_result(request);
@@ -297,7 +297,7 @@ spdk_rpc_clear_trace_flag(struct spdk_jsonrpc_request *request,
 		goto invalid;
 	}
 
-	spdk_log_clear_trace_flag(req.flag);
+	spdk_log_clear_flag(req.flag);
 	free_rpc_trace_flag(&req);
 
 	w = spdk_jsonrpc_begin_result(request);
diff --git a/test/nvme/aer/aer.c b/test/nvme/aer/aer.c
index e102813fb2..22dfe4a539 100644
--- a/test/nvme/aer/aer.c
+++ b/test/nvme/aer/aer.c
@@ -293,7 +293,7 @@ usage(const char *program_name)
 	printf("     subnqn      Subsystem NQN (default: %s)\n", SPDK_NVMF_DISCOVERY_NQN);
 	printf("    Example: -r 'trtype:RDMA adrfam:IPv4 traddr:192.168.100.8 trsvcid:4420'\n");
 
-	spdk_tracelog_usage(stdout, "-L");
+	spdk_log_usage(stdout, "-L");
 
 	printf(" -v         verbose (enable warnings)\n");
 	printf(" -H         show this usage\n");
@@ -319,7 +319,7 @@ parse_args(int argc, char **argv)
 			}
 			break;
 		case 'L':
-			rc = spdk_log_set_trace_flag(optarg);
+			rc = spdk_log_set_flag(optarg);
 			if (rc < 0) {
 				fprintf(stderr, "unknown flag\n");
 				usage(argv[0]);
diff --git a/test/unit/lib/log/log.c/log_ut.c b/test/unit/lib/log/log.c/log_ut.c
index 17650f719b..19fe3d210e 100644
--- a/test/unit/lib/log/log.c/log_ut.c
+++ b/test/unit/lib/log/log.c/log_ut.c
@@ -65,21 +65,21 @@ log_test(void)
 	CU_ASSERT_EQUAL(spdk_log_get_print_level(), SPDK_LOG_DEBUG);
 
 #ifdef DEBUG
-	CU_ASSERT(spdk_log_get_trace_flag("log") == false);
+	CU_ASSERT(spdk_log_get_flag("log") == false);
 
-	spdk_log_set_trace_flag("log");
-	CU_ASSERT(spdk_log_get_trace_flag("log") == true);
+	spdk_log_set_flag("log");
+	CU_ASSERT(spdk_log_get_flag("log") == true);
 
-	spdk_log_clear_trace_flag("log");
-	CU_ASSERT(spdk_log_get_trace_flag("log") == false);
+	spdk_log_clear_flag("log");
+	CU_ASSERT(spdk_log_get_flag("log") == false);
 #endif
 
 	spdk_log_open();
-	spdk_log_set_trace_flag("log");
+	spdk_log_set_flag("log");
 	SPDK_WARNLOG("log warning unit test\n");
 	SPDK_DEBUGLOG(SPDK_LOG_LOG, "log trace test\n");
 	SPDK_TRACEDUMP(SPDK_LOG_LOG, "log trace dump test:", "trace dump", 10);
-	spdk_trace_dump(stderr, "spdk dump test:", "spdk dump", 9);
+	spdk_log_dump(stderr, "spdk dump test:", "spdk dump", 9);
 
 	spdk_log_close();
 }