From 52d3df7fefe30b05677db9055e68c666a071d89a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 12 Sep 2020 11:13:34 -0600 Subject: log: Allow LOG_DEBUG to always enable log output At present if CONFIG_LOG enabled, putting LOG_DEBUG at the top of a file (before log.h inclusion) causes _log() to be executed for every log() call, regardless of the build- or run-time logging level. However there is no guarantee that the log record will actually be displayed. If the current log level is lower than LOGL_DEBUG then it will not be. Add a way to signal that the log record should always be displayed and update log_passes_filters() to handle this. With the new behaviour, log_debug() will always log if LOG_DEBUG is enabled. Move log_test_syslog_nodebug() into its own file since it cannot be made to work where it is, with LOG_DEBUG defined. Signed-off-by: Simon Glass --- common/log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'common/log.c') diff --git a/common/log.c b/common/log.c index 9a5f100..ac34f1c 100644 --- a/common/log.c +++ b/common/log.c @@ -157,6 +157,9 @@ static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec) { struct log_filter *filt; + if (rec->force_debug) + return true; + /* If there are no filters, filter on the default log level */ if (list_empty(&ldev->filter_head)) { if (rec->level > gd->default_log_level) @@ -219,7 +222,8 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, va_list args; rec.cat = cat; - rec.level = level; + rec.level = level & LOGL_LEVEL_MASK; + rec.force_debug = level & LOGL_FORCE_DEBUG; rec.file = file; rec.line = line; rec.func = func; -- cgit v1.1