diff mbox series

[5/7] trace-cmd listen: Add --verbose

Message ID 20210428074630.757694-6-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Headers show
Series Add --verbose option to bunch of trace-cmd commands | expand

Commit Message

Tzvetomir Stoyanov (VMware) April 28, 2021, 7:46 a.m. UTC
Add new "trace-cmd listen --verbose" argument for setting the desired
log level.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 Documentation/trace-cmd/trace-cmd-listen.1.txt | 8 ++++++++
 tracecmd/trace-listen.c                        | 6 ++++++
 tracecmd/trace-usage.c                         | 1 +
 3 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/trace-cmd/trace-cmd-listen.1.txt b/Documentation/trace-cmd/trace-cmd-listen.1.txt
index 8697328c..da841867 100644
--- a/Documentation/trace-cmd/trace-cmd-listen.1.txt
+++ b/Documentation/trace-cmd/trace-cmd-listen.1.txt
@@ -36,6 +36,14 @@  OPTIONS
 *-l* 'filename'::
     This option writes the output messages to a log file instead of standard output.
 
+*--verbose* 'level'::
+     Set the log level. Supported log levels are "none", "critical", "error", "warning",
+     "info", "debug", "all" or their identifiers "0", "1", "2", "3", "4", "5", "6". Setting the log
+     level to specific value enables all logs from that and all previous levels.
+
+     Example: enable all critical, error and warning logs
+
+      trace-cmd listen --verbose warning
 
 SEE ALSO
 --------
diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c
index 0ae1c948..a72365a2 100644
--- a/tracecmd/trace-listen.c
+++ b/tracecmd/trace-listen.c
@@ -916,6 +916,7 @@  static void start_daemon(void)
 }
 
 enum {
+	OPT_verbose	= 254,
 	OPT_debug	= 255,
 };
 
@@ -938,6 +939,7 @@  void trace_listen(int argc, char **argv)
 			{"port", required_argument, NULL, 'p'},
 			{"help", no_argument, NULL, '?'},
 			{"debug", no_argument, NULL, OPT_debug},
+			{"verbose", required_argument, NULL, OPT_verbose},
 			{NULL, 0, NULL, 0}
 		};
 
@@ -967,6 +969,10 @@  void trace_listen(int argc, char **argv)
 		case OPT_debug:
 			tracecmd_set_debug(true);
 			break;
+		case OPT_verbose:
+			if (trace_set_verbose(optarg) < 0)
+				die("invalid verbose level %s", optarg);
+			break;
 		default:
 			usage(argv);
 		}
diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c
index 10f06467..4c8b1300 100644
--- a/tracecmd/trace-usage.c
+++ b/tracecmd/trace-usage.c
@@ -300,6 +300,7 @@  static struct usage_help usage_help[] = {
 		"          -o file name to use for clients.\n"
 		"          -d directory to store client files.\n"
 		"          -l logfile to write messages to.\n"
+		"          --verbose 'level' Set the desired log level\n"
 	},
 #ifdef VSOCK
 	{