trace-cmd: Do not require --verbose to have an argument
PATCH 1/1 trace-cmd: Do not require --verbose to have an argument
From: "Steven Rostedt (VMware)" <[email protected]>
In most applications, when specifying a "verbose" argument, they do not require adding a level of verbosity. Just saying "--verbose" should be sufficient, unless they want a specific type of verbosity.
Have --verbose be acceptable as an argument without specifying a level. If no level is given, the the verbosity will default to "info".
Unfortunately, it appears that getopt_long() does not recognize the next argument on the command line as an optional argument, but requires an equal sign between the "--verbose" and the level. That is, when the user wants to specify a specific level, they need to do it like so:
trace-cmd report --verbose=debug
And not like:
trace-cmd report --verbose debug
The man pages are updated to reflect this.
---
This patch is based on top of Tzvetomir's patch set found here:
https://lore.kernel.org/linux-trace-devel/[email protected]/
Documentation/trace-cmd/trace-cmd-check-events.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-dump.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-extract.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-listen.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-profile.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-record.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-report.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-set.1.txt | 5 +++-- Documentation/trace-cmd/trace-cmd-stack.1.txt | 5 +++-- tracecmd/trace-agent.c | 2 +- tracecmd/trace-check-events.c | 2 +- tracecmd/trace-cmd.c | 3 ++- tracecmd/trace-dump.c | 2 +- tracecmd/trace-listen.c | 2 +- tracecmd/trace-read.c | 2 +- tracecmd/trace-record.c | 2 +- tracecmd/trace-stack.c | 2 +- 17 files changed, 36 insertions(+), 26 deletions(-)
Documentation/trace-cmd/trace-cmd-check-events.1.txt +3 -2
@@ -24,14 +24,15 @@ OPTIONS ------- *-N* - Don't load plugins -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd check-events --verbose warning + trace-cmd check-events --verbose=warning SEE ALSO --------
Documentation/trace-cmd/trace-cmd-dump.1.txt +3 -2
@@ -52,14 +52,15 @@ OPTIONS Print all meta data from the file. *--help*:: Print usage information. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd report --verbose warning + trace-cmd report --verbose=warning EXAMPLES --------
Documentation/trace-cmd/trace-cmd-extract.1.txt +3 -2
@@ -67,14 +67,15 @@ OPTIONS this is the same as the default. But if *-B* or *-a* is used, this is required if the top level instance buffer should also be extracted. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd extract --verbose warning + trace-cmd extract --verbose=warning SEE ALSO --------
Documentation/trace-cmd/trace-cmd-listen.1.txt +3 -2
@@ -36,14 +36,15 @@ OPTIONS *-l* 'filename':: This option writes the output messages to a log file instead of standard output. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd listen --verbose warning + trace-cmd listen --verbose=warning SEE ALSO --------
Documentation/trace-cmd/trace-cmd-profile.1.txt +3 -2
@@ -90,14 +90,15 @@ These are the same as trace-cmd-record(1) with the *--profile* option. is not changed. This allows watching the command execute and saving the output of the profile to another file. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd profile --verbose warning + trace-cmd profile --verbose=warning EXAMPLES --------
Documentation/trace-cmd/trace-cmd-record.1.txt +3 -2
@@ -360,14 +360,15 @@ OPTIONS executed will not be changed. This is useful if you want to monitor the output of the command being executed, but not see the output from trace-cmd. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd record --verbose warning + trace-cmd record --verbose=warning EXAMPLES --------
Documentation/trace-cmd/trace-cmd-report.1.txt +3 -2
@@ -315,14 +315,15 @@ OPTIONS *--align-ts*:: Display timestamps aligned to the first event. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd report --verbose warning + trace-cmd report --verbose=warning EXAMPLES --------
Documentation/trace-cmd/trace-cmd-set.1.txt +3 -2
@@ -227,14 +227,15 @@ OPTIONS unless the *--fork* option is specified. Then it will fork the command and return immediately. -*--verbose* 'level':: +*--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. + The level will default to "info" if one is not specified. Example: enable all critical, error and warning logs - trace-cmd set --verbose warning + trace-cmd set --verbose=warning EXAMPLES --------
Documentation/trace-cmd/trace-cmd-stack.1.txt +3 -2
@@ -24,9 +24,10 @@ stack found since the start was enabled. Use *--reset* to reset the stack counter to zero. -User *--verbose* 'level' to set the log level. Supported log levels are "none", "critical", "error", +User *--verbose*[='level'] to 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. +the log level to specific value enables all logs from that and all previous levels. The level will +default to "info" if one is not specified. SEE ALSO --------
tracecmd/trace-agent.c +1 -1
@@ -302,7 +302,7 @@ void trace_agent(int argc, char **argv) {"port", required_argument, NULL, 'p'}, {"help", no_argument, NULL, '?'}, {"debug", no_argument, NULL, DO_DEBUG}, - {"verbose", required_argument, NULL, OPT_verbose}, + {"verbose", optional_argument, NULL, OPT_verbose}, {NULL, 0, NULL, 0} };
tracecmd/trace-check-events.c +1 -1
@@ -24,7 +24,7 @@ void trace_check_events(int argc, char **argv)int open_flags =0 ;int option_index =0 ;static struct option long_options[] = { - {"verbose" , required_argument,NULL , OPT_verbose}, + {"verbose" , optional_argument,NULL , OPT_verbose}, {NULL ,0 ,NULL ,0 } };
tracecmd/trace-cmd.c +2 -1
@@ -62,8 +62,9 @@ int trace_set_verbose(char *level) {int id; +/* Default level is info */ if (!level) -return -1 ; + level ="info" ;if (isdigit (level[0 ])) { id =atoi (level);
tracecmd/trace-dump.c +1 -1
@@ -723,7 +723,7 @@ void trace_dump(int argc, char **argv) {"clock", no_argument, NULL, OPT_clock}, {"validate", no_argument, NULL, 'v'}, {"help", no_argument, NULL, '?'}, - {"verbose", required_argument, NULL, OPT_verbose}, + {"verbose", optional_argument, NULL, OPT_verbose}, {NULL, 0, NULL, 0} };
tracecmd/trace-listen.c +1 -1
@@ -939,7 +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}, + {"verbose", optional_argument, NULL, OPT_verbose}, {NULL, 0, NULL, 0} };
tracecmd/trace-read.c +1 -1
@@ -1603,7 +1603,7 @@ void trace_report (int argc, char **argv) {"ts-check", no_argument, NULL, OPT_tscheck}, {"raw-ts", no_argument, NULL, OPT_raw_ts}, {"align-ts", no_argument, NULL, OPT_align_ts}, - {"verbose", required_argument, NULL, OPT_verbose}, + {"verbose", optional_argument, NULL, OPT_verbose}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} };
tracecmd/trace-record.c +1 -1
@@ -6173,7 +6173,7 @@ static void parse_record_options(int argc, {"tsync-interval", required_argument, NULL, OPT_tsyncinterval}, {"fork", no_argument, NULL, OPT_fork}, {"tsc2nsec", no_argument, NULL, OPT_tsc2nsec}, - {"verbose", required_argument, NULL, OPT_verbose}, + {"verbose", optional_argument, NULL, OPT_verbose}, {NULL, 0, NULL, 0} };
tracecmd/trace-stack.c +1 -1
@@ -164,7 +164,7 @@ void trace_stack (int argc, char **argv) {"stop", no_argument, NULL, OPT_stop}, {"reset", no_argument, NULL, OPT_reset}, {"help", no_argument, NULL, '?'}, - {"verbose", required_argument, NULL, OPT_verbose}, + {"verbose", optional_argument, NULL, OPT_verbose}, {NULL, 0, NULL, 0} };
Signature · 1 line
2.29.2