Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/8] trace-cmd library: Add tracecmd_info() log function
Date: Wed, 28 Apr 2021 10:41:43 +0300
Message-ID: <20210428074149.757163-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com>

The pr_stat() function is removed from the traceevent library. This function
was used by trace-cmd to print statistics. Introduce tracecmd_info() log
function and replace 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, add 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(-)

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 b17b36e0..733e1858 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3280,7 +3280,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 4228b055..77259357 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, 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 fa942215..229b54f3 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 fd03a605..8805b10e 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)
-- 
2.30.2


  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28  7:41 [PATCH 0/8] Changes to trace-cmd logs Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` [PATCH 1/8] trace-cmd library: Use tep_vprint() for logs Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` Tzvetomir Stoyanov (VMware) [this message]
2021-04-28  7:41 ` [PATCH 3/8] trace-cmd library: Add log levels Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` [PATCH 4/8] trace-cmd library: Document the API for " Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` [PATCH 5/8] trace-cmd library: Renamed tracecmd_fatal() to tracecmd_critical() Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` [PATCH 6/8] trace-cmd library: Set debug log level in debug mode Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` [PATCH 7/8] trace-cmd report: Set the log level with -V and -q options Tzvetomir Stoyanov (VMware)
2021-04-28  7:41 ` [PATCH 8/8] trace-cmd: Add new function to set log level Tzvetomir Stoyanov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210428074149.757163-3-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git