diff options
author | Simon Glass <sjg@chromium.org> | 2017-12-28 13:14:16 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-02-03 10:09:13 -0700 |
commit | f941c8d76c665045e5d645112a309d12523e19c7 (patch) | |
tree | c9ed5205c536521ea53c252a303214f52d1f415f /include/log.h | |
parent | 6e43d1b19982b1756b7c607569d1778e556d6577 (diff) | |
download | u-boot-f941c8d76c665045e5d645112a309d12523e19c7.zip u-boot-f941c8d76c665045e5d645112a309d12523e19c7.tar.gz u-boot-f941c8d76c665045e5d645112a309d12523e19c7.tar.bz2 |
log: Add functions to convert IDs to/from names
Category and level both use an enum for their ID values. Add functions to
convert these IDs to strings and vice versa. This will allow the log to
output the strings instead of the (inscrutable) values.
At the same time, add a new 'driver-model' category, to cover core
driver-model functions and fix an incorrect value for LOGL_MAX.
Tests will be added with the new 'log' subcommands.
Signed-off-by: Simon Glass <sjg@chromium.org>
(Updated to correct clang warnings)
Diffstat (limited to 'include/log.h')
-rw-r--r-- | include/log.h | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/include/log.h b/include/log.h index 8083b64..5133213 100644 --- a/include/log.h +++ b/include/log.h @@ -27,8 +27,10 @@ enum log_level_t { LOGL_DEBUG_IO, /* Debug message showing hardware I/O access */ LOGL_COUNT, + LOGL_NONE, + LOGL_FIRST = LOGL_EMERG, - LOGL_MAX = LOGL_DEBUG, + LOGL_MAX = LOGL_DEBUG_IO, }; /** @@ -42,7 +44,8 @@ enum log_category_t { LOGC_ARCH, LOGC_BOARD, LOGC_CORE, - LOGC_DT, + LOGC_DM, /* Core driver-model */ + LOGC_DT, /* Device-tree */ LOGC_COUNT, LOGC_END, @@ -256,6 +259,38 @@ struct log_filter { #define LOG_DRIVER(_name) \ ll_entry_declare(struct log_driver, _name, log_driver) +/** + * log_get_cat_name() - Get the name of a category + * + * @cat: Category to look up + * @return category name (which may be a uclass driver name) + */ +const char *log_get_cat_name(enum log_category_t cat); + +/** + * log_get_cat_by_name() - Look up a category by name + * + * @name: Name to look up + * @return category ID, or LOGC_NONE if not found + */ +enum log_category_t log_get_cat_by_name(const char *name); + +/** + * log_get_level_name() - Get the name of a log level + * + * @level: Log level to look up + * @return log level name (in ALL CAPS) + */ +const char *log_get_level_name(enum log_level_t level); + +/** + * log_get_level_by_name() - Look up a log level by name + * + * @name: Name to look up + * @return log level ID, or LOGL_NONE if not found + */ +enum log_level_t log_get_level_by_name(const char *name); + /* Handle the 'log test' command */ int do_log_test(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); |