]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: track verbose level
authorDaniel Wagner <dwagner@suse.de>
Wed, 6 Mar 2024 08:36:23 +0000 (09:36 +0100)
committerDaniel Wagner <wagi@monom.org>
Thu, 7 Mar 2024 07:10:30 +0000 (08:10 +0100)
The command line option parser is able to count how many times 'verbose'
is provided by the user. This increases the verbosity level. Use this
for mapping it to the correct log_level.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index b77b22546151db9e807fae2f46f779f9cafb27eb..509a15eca5e70a2e1ec348b7afb02472e2d27a9f 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -110,7 +110,7 @@ struct passthru_config {
 
 #define NVME_ARGS(n, ...)                                                         \
        struct argconfig_commandline_options n[] = {                              \
-               OPT_FLAG("verbose",      'v', NULL,               verbose),       \
+               OPT_INCR("verbose",      'v', &verbose_level,     verbose),       \
                OPT_FMT("output-format", 'o', &output_format_val, output_format), \
                ##__VA_ARGS__,                                                    \
                OPT_END()                                                         \
@@ -188,6 +188,7 @@ static const char dash[51] = {[0 ... 49] = '=', '\0'};
 static const char space[51] = {[0 ... 49] = ' ', '\0'};
 
 static char *output_format_val = "normal";
+int verbose_level;
 
 static void *mmap_registers(nvme_root_t r, struct nvme_dev *dev);
 
@@ -3223,7 +3224,7 @@ static int list_subsys(int argc, char **argv, struct command *cmd,
        if (argconfig_parse_seen(opts, "verbose"))
                flags |= VERBOSE;
 
-       log_level = map_log_level(!!(flags & VERBOSE), false);
+       log_level = map_log_level(verbose_level, false);
 
        r = nvme_create_root(stderr, log_level);
        if (!r) {
@@ -3282,7 +3283,7 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
        if (argconfig_parse_seen(opts, "verbose"))
                flags |= VERBOSE;
 
-       log_level = map_log_level(!!(flags & VERBOSE), false);
+       log_level = map_log_level(verbose_level, false);
 
        r = nvme_create_root(stderr, log_level);
        if (!r) {
@@ -8865,7 +8866,7 @@ static int show_topology_cmd(int argc, char **argv, struct command *command, str
                return -EINVAL;
        }
 
-       log_level = map_log_level(!!(flags & VERBOSE), false);
+       log_level = map_log_level(verbose_level, false);
 
        r = nvme_create_root(stderr, log_level);
        if (!r) {