[PATCH 2/4] libtraceevent: Have logs only print to stderr on WARNING or higher

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

The tep logs should only print to stderr for WARNINGS and higher. Info
messages can go to stdout.

Also, only print perror on warnings or higher.

Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 src/parse-utils.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/parse-utils.c b/src/parse-utils.c
index 3f4918f7468e..09059edf0159 100644
--- a/src/parse-utils.c
+++ b/src/parse-utils.c
@@ -67,13 +67,17 @@ int __tep_vprint(const char *name, enum tep_loglevel level,
 		      bool print_err, const char *fmt, va_list ap)
 {
 	int ret = errno;
-
-	if (errno && print_err) {
-		perror(name);
-		fprintf(stderr, "  ");
+	FILE *fp = stdout;
+
+	if (level <= TEP_LOG_WARNING) {
+		fp = stderr;
+		if (errno && print_err) {
+			perror(name);
+			fprintf(stderr, "  ");
+		}
 	}
-	vfprintf(stderr, fmt, ap);
-	fprintf(stderr, "\n");
+	vfprintf(fp, fmt, ap);
+	fprintf(fp, "\n");
 
 	return ret;
 }
-- 
2.34.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux