cli: add short option `-l` for `--log-level`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 16 Apr 2018 22:56:26 +0000 (18:56 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
cli/babeltrace-cfg-cli-args.c
doc/man/babeltrace.1.txt

index 9d2b684edaa4e11a13d9a74aa613650f84de2ac0..6182f1a74b321e7fa94cf0d8bc01bca597400ae1 100644 (file)
@@ -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",
index cd05dbf61afbc0a5f898c2d4ca1933399809c59f..a9cfdc89a98be682d256c46af6c05d9488b5df2b 100644 (file)
@@ -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,
This page took 0.026642 seconds and 4 git commands to generate.