From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Anderson Date: Tue, 27 Oct 2020 19:55:35 -0400 Subject: [PATCH v4 16/22] cmd: log: Make "log level" print all log levels In-Reply-To: <20201027235541.706077-1-seanga2@gmail.com> References: <20201027235541.706077-1-seanga2@gmail.com> Message-ID: <20201027235541.706077-17-seanga2@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This makes the log level command print all valid log levels. The default log level is annotated. This provides an easy way to see which log levels are compiled-in. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (no changes since v2) Changes in v2: - New cmd/log.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/log.c b/cmd/log.c index 8d8d8a8172..596bc73f47 100644 --- a/cmd/log.c +++ b/cmd/log.c @@ -34,14 +34,20 @@ static enum log_level_t parse_log_level(char *const arg) static int do_log_level(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + enum log_level_t log_level; + if (argc > 1) { - enum log_level_t log_level = parse_log_level(argv[1]); + log_level = parse_log_level(argv[1]); if (log_level == LOGL_NONE) return CMD_RET_FAILURE; gd->default_log_level = log_level; } else { - printf("Default log level: %d\n", gd->default_log_level); + for (log_level = LOGL_FIRST; log_level <= _LOG_MAX_LEVEL; + log_level++) + printf("%s%s\n", log_get_level_name(log_level), + log_level == gd->default_log_level ? + " (default)" : ""); } return CMD_RET_SUCCESS; @@ -153,7 +159,7 @@ static int do_log_rec(struct cmd_tbl *cmdtp, int flag, int argc, #ifdef CONFIG_SYS_LONGHELP static char log_help_text[] = - "level - get/set log level\n" + "level [] - get/set log level\n" "categories - list log categories\n" "drivers - list log drivers\n" "log format - set log output format. is a string where\n" -- 2.28.0