summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2020-10-27 19:55:34 -0400
committerTom Rini <trini@konsulko.com>2020-10-30 10:56:10 -0400
commit1c593a105abd3ab5f551e04fbb427a56a4120cc9 (patch)
tree66b223ba52c199d4d3275282523c507abbc88348 /cmd
parentfed9c2fbc941660f3a6ea25013f6501d4cff8f86 (diff)
cmd: log: Add commands to list categories and drivers
This allows users to query which categories and drivers are available on their system. This allows them to construct filter-add commands without (e.g.) adjusting the log format to show categories and drivers. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/log.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/cmd/log.c b/cmd/log.c
index 651e50358c..8d8d8a8172 100644
--- a/cmd/log.c
+++ b/cmd/log.c
@@ -47,6 +47,37 @@ static int do_log_level(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}
+static int do_log_categories(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ enum log_category_t cat;
+ const char *name;
+
+ for (cat = LOGC_FIRST; cat < LOGC_COUNT; cat++) {
+ name = log_get_cat_name(cat);
+ /*
+ * Invalid category names (e.g. <invalid> or <missing>) begin
+ * with '<'.
+ */
+ if (name[0] == '<')
+ continue;
+ printf("%s\n", name);
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+static int do_log_drivers(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct log_device *ldev;
+
+ list_for_each_entry(ldev, &gd->log_head, sibling_node)
+ printf("%s\n", ldev->drv->name);
+
+ return CMD_RET_SUCCESS;
+}
+
static int do_log_format(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -123,6 +154,8 @@ 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"
+ "categories - list log categories\n"
+ "drivers - list log drivers\n"
"log format <fmt> - set log output format. <fmt> is a string where\n"
"\teach letter indicates something that should be displayed:\n"
"\tc=category, l=level, F=file, L=line number, f=function, m=msg\n"
@@ -134,6 +167,8 @@ static char log_help_text[] =
U_BOOT_CMD_WITH_SUBCMDS(log, "log system", log_help_text,
U_BOOT_SUBCMD_MKENT(level, 2, 1, do_log_level),
+ U_BOOT_SUBCMD_MKENT(categories, 1, 1, do_log_categories),
+ U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_log_drivers),
U_BOOT_SUBCMD_MKENT(format, 2, 1, do_log_format),
U_BOOT_SUBCMD_MKENT(rec, 7, 1, do_log_rec),
);