diff mbox series

[v2,2/8] trace-cmd library: Add tracecmd_info() log function

Message ID 20210507095333.1080910-3-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Headers show
Series Changes to trace-cmd logs | expand

Commit Message

Tzvetomir Stoyanov (VMware) May 7, 2021, 9:53 a.m. UTC
The pr_stat() function is removed from the traceevent library. This function
was used by trace-cmd to print statistics. Introduced tracecmd_info() log
function and replaced pr_stat() with it in the trace-cmd library.
However, pr_stat() is used also in the trace-cmd application. In order no
to change the existing behaviour, added a static pr_stat() implementation for
that usage.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/include/trace-cmd-local.h |  1 +
 lib/trace-cmd/trace-input.c             |  2 +-
 lib/trace-cmd/trace-plugin.c            |  2 +-
 lib/trace-cmd/trace-util.c              | 10 ++++++++++
 python/ctracecmd.i                      | 11 -----------
 tracecmd/trace-cmd.c                    | 14 --------------
 tracecmd/trace-record.c                 | 14 ++++++++++++++
 7 files changed, 27 insertions(+), 27 deletions(-)

Comments

Steven Rostedt May 13, 2021, 9:22 p.m. UTC | #1
On Fri,  7 May 2021 12:53:27 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -2934,6 +2934,20 @@ static void test_event(struct event_list *event, const char *path,
>  
>  	*save = event;
>  }
> +static void pr_stat(const char *fmt, ...)
> +{
> +	va_list ap;
> +
> +	if (!show_status)
> +		return;
> +
> +	va_start(ap, fmt);
> +	vprintf(fmt, ap);
> +	va_end(ap);
> +
> +	printf("\n");
> +}
> +
>  

Since we need to keep the library pr_stat() for backward compatibility, I
rename this to "print_event()" as that's what it was doing locally anyway.

Otherwise it conflicted with the old pr_stat() that I added back to
libtraceevent.

-- Steve
diff mbox series

Patch

diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h
index e8533b22..cd868f60 100644
--- a/lib/trace-cmd/include/trace-cmd-local.h
+++ b/lib/trace-cmd/include/trace-cmd-local.h
@@ -12,6 +12,7 @@ 
 /* Can be overridden */
 void tracecmd_warning(const char *fmt, ...);
 void tracecmd_fatal(const char *fmt, ...);
+void tracecmd_info(const char *fmt, ...);
 
 /* trace.dat file format version */
 #define FILE_VERSION 6
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 9726e994..2e519752 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3292,7 +3292,7 @@  struct tracecmd_input *tracecmd_alloc_fd(int fd, int flags)
 	version = read_string(handle);
 	if (!version)
 		goto failed_read;
-	pr_stat("version = %s\n", version);
+	tracecmd_info("version = %s\n", version);
 	free(version);
 
 	if (do_read_check(handle, buf, 1))
diff --git a/lib/trace-cmd/trace-plugin.c b/lib/trace-cmd/trace-plugin.c
index ca7cadae..50c800c2 100644
--- a/lib/trace-cmd/trace-plugin.c
+++ b/lib/trace-cmd/trace-plugin.c
@@ -140,7 +140,7 @@  load_plugin(struct trace_plugin_context *trace, const char *path,
 	list->name = plugin;
 	*plugin_list = list;
 
-	pr_stat("registering plugin: %s", plugin);
+	tracecmd_info("registering plugin: %s", plugin);
 	func(trace);
 	return;
 
diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c
index ab77ce2a..049fe049 100644
--- a/lib/trace-cmd/trace-util.c
+++ b/lib/trace-cmd/trace-util.c
@@ -364,6 +364,16 @@  void __weak tracecmd_warning(const char *fmt, ...)
 	va_end(ap);
 }
 
+void tracecmd_info(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	tep_vprint("libtracecmd", TEP_LOG_INFO, false, fmt, ap);
+	va_end(ap);
+}
+
+
 void __weak tracecmd_fatal(const char *fmt, ...)
 {
 	int ret;
diff --git a/python/ctracecmd.i b/python/ctracecmd.i
index 7091b9bd..6d0179e3 100644
--- a/python/ctracecmd.i
+++ b/python/ctracecmd.i
@@ -44,17 +44,6 @@  static void py_supress_trace_output(void)
 	skip_output = 1;
 }
 
-void pr_stat(const char *fmt, ...)
-{
-        va_list ap;
-
-	if (skip_output)
-		return;
-	va_start(ap, fmt);
-	__vpr_stat(fmt, ap);
-	va_end(ap);
-}
-
 void warning(const char *fmt, ...)
 {
 	va_list ap;
diff --git a/tracecmd/trace-cmd.c b/tracecmd/trace-cmd.c
index 7376c5a5..60cd3ea1 100644
--- a/tracecmd/trace-cmd.c
+++ b/tracecmd/trace-cmd.c
@@ -35,20 +35,6 @@  void warning(const char *fmt, ...)
 	fprintf(stderr, "\n");
 }
 
-void pr_stat(const char *fmt, ...)
-{
-	va_list ap;
-
-	if (!show_status)
-		return;
-
-	va_start(ap, fmt);
-	vprintf(fmt, ap);
-	va_end(ap);
-
-	printf("\n");
-}
-
 void *malloc_or_die(unsigned int size)
 {
 	void *data;
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 5dd8be4a..274d706c 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -2934,6 +2934,20 @@  static void test_event(struct event_list *event, const char *path,
 
 	*save = event;
 }
+static void pr_stat(const char *fmt, ...)
+{
+	va_list ap;
+
+	if (!show_status)
+		return;
+
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+
+	printf("\n");
+}
+
 
 static int expand_event_files(struct buffer_instance *instance,
 			      const char *file, struct event_list *old_event)