mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: <rostedt@goodmis.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] trace-cmd: allow python tools to supress warning() and pr_stat()
Date: Fri, 26 Sep 2014 14:44:34 -0400	[thread overview]
Message-ID: <1411757074-29117-1-git-send-email-jbacik@fb.com> (raw)

trace-cmd has a lot of built in warning() and pr_stat() output that is noisy
when you are using the python bindings.  This patch provides overrides for these
two functions and the ability for python scripts to optionally turn them off.
With this patch I can silence all of these extraneous print messages from within
my python script.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 ctracecmd.i | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/ctracecmd.i b/ctracecmd.i
index 3b80f01..e91d068 100644
--- a/ctracecmd.i
+++ b/ctracecmd.i
@@ -34,6 +34,36 @@ static int python_callback(struct trace_seq *s,
 			   struct event_format *event,
 			   void *context);
 
+static int skip_output = 0;
+
+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;
+
+	if (skip_output)
+		return;
+
+	va_start(ap, fmt);
+	__vwarning(fmt, ap);
+	va_end(ap);
+}
+
 PyObject *convert_pevent(unsigned long pevent)
 {
 	void *pev = (void *)pevent;
-- 
1.9.3


                 reply	other threads:[~2014-09-26 18:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1411757074-29117-1-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.com \
    --cc=linux-kernel@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®