aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass2018-10-01 11:55:06 -0600
committerSimon Glass2018-10-09 04:40:26 -0600
commitcdd140af5c6b623d31ac87a8054cee55fb70d3f0 (patch)
tree2611fa049af667c73e353be43fb8a5aa11c4c7f1 /include
parentfbcf37e48ebb9829c85651378191e33f6ece710e (diff)
log: Add helpers for common log levels
At present to output a log message you need something like: log(UCLASS_SPI, LOCL_INFO, "message1"); log(UCLASS_SPI, LOCL_INFO, "message2"); but many files use the same category throughout. Also it is helpful to shorten the length of log names, providing helpers for common logging levels. Add some macros so that it is possible to do: (top of file, before #includes) #define LOG_CATEGORY UCLASS_SPI (later in the file) log_info("message1"); log_debug("message2"); log_err("message3"); Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/log.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/log.h b/include/log.h
index 75ff1e1160c..1d936ec9523 100644
--- a/include/log.h
+++ b/include/log.h
@@ -88,8 +88,22 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
*/
#if CONFIG_IS_ENABLED(LOG)
#define _LOG_MAX_LEVEL CONFIG_VAL(LOG_MAX_LEVEL)
+#define log_err(_fmt...) log(LOG_CATEGORY, LOGL_ERR, ##_fmt)
+#define log_warning(_fmt...) log(LOG_CATEGORY, LOGL_WARNING, ##_fmt)
+#define log_notice(_fmt...) log(LOG_CATEGORY, LOGL_NOTICE, ##_fmt)
+#define log_info(_fmt...) log(LOG_CATEGORY, LOGL_INFO, ##_fmt)
+#define log_debug(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
+#define log_content(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_CONTENT, ##_fmt)
+#define log_io(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
#else
#define _LOG_MAX_LEVEL LOGL_INFO
+#define log_err(_fmt...)
+#define log_warning(_fmt...)
+#define log_notice(_fmt...)
+#define log_info(_fmt...)
+#define log_debug(_fmt...)
+#define log_content(_fmt...)
+#define log_io(_fmt...)
#endif
/* Emit a log record if the level is less that the maximum */