Skip to contentSkip to conversation

trace-cmd library: Only set trace-cmd log level

PATCH New Steven Rostedt 1 participant 1 message Oct 6, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd library: Only set trace-cmd log level

From: "Steven Rostedt (Google)" <[email protected]>

Have tracecmd_set_loglevel() only for trace-cmd and not touch libtracefs and libtraceevent log levels. Let the application handle this instead.

Update the trace-cmd code to keep the same reporting.

Move the updates of libtracefs and libtraceevent log levels from the library into the application.

---
 lib/trace-cmd/trace-util.c     |  4 +---
 tracecmd/include/trace-local.h |  1 +
 tracecmd/trace-cmd.c           | 11 +++++++++--
 tracecmd/trace-read.c          |  2 ++
 4 files changed, 13 insertions(+), 5 deletions(-)
lib/trace-cmd/trace-util.c +1 -3
index 108e20cf4b7d..fc61f9d1111b 100644
@@ -31,7 +31,7 @@
 
 static bool debug;
 static bool notimeout;
-static int log_level = TEP_LOG_INFO;
+static int log_level = TEP_LOG_WARNING;
 static FILE *logfp;
 
 const static struct {
@@ -393,8 +393,6 @@ trace_load_plugins(struct tep_handle *tep, int flags)
 void tracecmd_set_loglevel(enum tep_loglevel level)
 {
 	log_level = level;
-	tracefs_set_loglevel(level);
-	tep_set_loglevel(level);
 }
 
 void __weak tracecmd_warning(const char *fmt, ...)
tracecmd/include/trace-local.h +1 -0
index a48a14a5a387..023afb3baad1 100644
@@ -40,6 +40,7 @@ void usage(char **argv);
 extern int silence_warnings;
 extern int show_status;
 
+void trace_set_loglevel(int level);
 int trace_set_verbose(char *level);
 
 enum port_type {
tracecmd/trace-cmd.c +9 -2
index 69800d26c5ee..9646921ca268 100644
@@ -76,6 +76,13 @@ static struct trace_log_severity {
 	{ .id = TEP_LOG_ALL, .name = "all" },
 };
 
+void trace_set_loglevel(int level)
+{
+	tracecmd_set_loglevel(level);
+	tracefs_set_loglevel(level);
+	tep_set_loglevel(level);
+}
+
 int trace_set_verbose(char *level)
 {
 	int id;
@@ -89,7 +96,7 @@ int trace_set_verbose(char *level)
 		if (id >= TEP_LOG_NONE) {
 			if (id > TEP_LOG_ALL)
 				id = TEP_LOG_ALL;
-			tracecmd_set_loglevel(id);
+			trace_set_loglevel(id);
 			return 0;
 		}
 	} else {
@@ -98,7 +105,7 @@ int trace_set_verbose(char *level)
 
 		for (i = 0; i < size; i++) {
 			if (!strncmp(level, log_severity[i].name, strlen(log_severity[i].name))) {
-				tracecmd_set_loglevel(log_severity[i].id);
+				trace_set_loglevel(log_severity[i].id);
 				return 0;
 			}
 		}
tracecmd/trace-read.c +2 -0
index b8931cf95543..d51e3371456f 100644
@@ -1565,6 +1565,8 @@ void trace_report (int argc, char **argv)
 
 	signal(SIGINT, sig_end);
 
+	trace_set_loglevel(TEP_LOG_INFO);
+
 	for (;;) {
 		int option_index = 0;
 		static struct option long_options[] = {
Signature · 1 line
2.35.1