summaryrefslogtreecommitdiff
path: root/common/log.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-20 20:10:52 -0700
committerTom Rini <trini@konsulko.com>2021-03-12 17:41:35 -0500
commit79d5983b61e41d5c586489b03e75a75961d31041 (patch)
tree0d2e23263b1656013685cfea2943798ba43389a5 /common/log.c
parentc57ec2c2bab00c02a457ca70624c1333c60c2ec0 (diff)
log: Set up a flag byte for log records
At present only a single flag (force_debug) is used in log records. Before adding more, convert this into a bitfield, so more can be added without using more space. To avoid expanding the log_record struct itself (which some drivers may wish to store in memory) reduce the line-number field to 16 bits. This provides for up to 64K lines which should be enough for anyone. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/log.c')
-rw-r--r--common/log.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/log.c b/common/log.c
index 6b0034c3ba..f87e33a9ca 100644
--- a/common/log.c
+++ b/common/log.c
@@ -153,7 +153,7 @@ static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec)
{
struct log_filter *filt;
- if (rec->force_debug)
+ if (rec->flags & LOGRECF_FORCE_DEBUG)
return true;
/* If there are no filters, filter on the default log level */
@@ -245,7 +245,9 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
rec.cat = cat;
rec.level = level & LOGL_LEVEL_MASK;
- rec.force_debug = level & LOGL_FORCE_DEBUG;
+ rec.flags = 0;
+ if (level & LOGL_FORCE_DEBUG)
+ rec.flags |= LOGRECF_FORCE_DEBUG;
rec.file = file;
rec.line = line;
rec.func = func;
@@ -255,7 +257,8 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
gd->log_drop_count++;
/* display dropped traces with console puts and DEBUG_UART */
- if (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug) {
+ if (rec.level <= CONFIG_LOG_DEFAULT_LEVEL ||
+ rec.flags & LOGRECF_FORCE_DEBUG) {
char buf[CONFIG_SYS_CBSIZE];
va_start(args, fmt);