From 5bd4da003739c77837ba154f2b80e363fa7b1aab Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 16 Apr 2018 18:56:26 -0400 Subject: [PATCH] cli: add short option `-l` for `--log-level` Signed-off-by: Philippe Proulx --- cli/babeltrace-cfg-cli-args.c | 15 +++++++++++++-- doc/man/babeltrace.1.txt | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cli/babeltrace-cfg-cli-args.c b/cli/babeltrace-cfg-cli-args.c index 9d2b684e..6182f1a7 100644 --- a/cli/babeltrace-cfg-cli-args.c +++ b/cli/babeltrace-cfg-cli-args.c @@ -4774,7 +4774,7 @@ void print_gen_usage(FILE *fp) fprintf(fp, "\n"); fprintf(fp, " -d, --debug Enable debug mode (same as --log-level=V)\n"); fprintf(fp, " -h, --help Show this help and quit\n"); - fprintf(fp, " --log-level=LVL Set all log levels to LVL (`N`, `V`, `D`,\n"); + fprintf(fp, " -l, --log-level=LVL Set all log levels to LVL (`N`, `V`, `D`,\n"); fprintf(fp, " `I`, `W` (default), `E`, or `F`)\n"); fprintf(fp, " -v, --verbose Enable verbose mode (same as --log-level=I)\n"); fprintf(fp, " -V, --version Show version and quit\n"); @@ -4881,7 +4881,8 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[], */ log_level = 'I'; } - } else if (strcmp(cur_arg, "--log-level") == 0) { + } else if (strcmp(cur_arg, "--log-level") == 0 || + strcmp(cur_arg, "-l") == 0) { if (!next_arg) { printf_err("Missing log level value for --log-level option\n"); *retcode = 1; @@ -4900,6 +4901,16 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[], } else if (strncmp(cur_arg, "--log-level=", 12) == 0) { const char *arg = &cur_arg[12]; + log_level = log_level_from_arg(arg); + if (log_level == 'U') { + printf_err("Invalid argument for --log-level option:\n %s\n", + arg); + *retcode = 1; + goto end; + } + } else if (strncmp(cur_arg, "-l", 2) == 0) { + const char *arg = &cur_arg[2]; + log_level = log_level_from_arg(arg); if (log_level == 'U') { printf_err("Invalid argument for --log-level option:\n %s\n", diff --git a/doc/man/babeltrace.1.txt b/doc/man/babeltrace.1.txt index cd05dbf6..a9cfdc89 100644 --- a/doc/man/babeltrace.1.txt +++ b/doc/man/babeltrace.1.txt @@ -51,7 +51,7 @@ opt:-d, opt:--debug:: + This is equivalent to opt:--log-level=`VERBOSE`. -opt:--log-level='LVL':: +opt:-l 'LVL', opt:--log-level='LVL':: Set the log level of all known Babeltrace loggers to 'LVL'. You can override the level of a specific logger with a dedicated log level environment variable. If you don't specify this option, -- 2.34.1