aboutsummaryrefslogtreecommitdiff
path: root/common/log_console.c
diff options
context:
space:
mode:
authorSimon Glass2017-12-28 13:14:18 -0700
committerSimon Glass2018-02-03 10:09:27 -0700
commitdeca50fbd594d9aa845fc724a1758a1f61011ddb (patch)
tree520eeb60afb998405a68fb0bc66daf311d70a708 /common/log_console.c
parent3b73e8d067fb7cb504bed2018583980a3cd3f4bc (diff)
log: Update log_console to honour the log format
At present this just outputs the message. Update it to output whatever the format requests. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/log_console.c')
-rw-r--r--common/log_console.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/common/log_console.c b/common/log_console.c
index 5af73bd8be4..29027330783 100644
--- a/common/log_console.c
+++ b/common/log_console.c
@@ -10,9 +10,34 @@
#include <common.h>
#include <log.h>
+DECLARE_GLOBAL_DATA_PTR;
+
static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
{
- puts(rec->msg);
+ int fmt = gd->log_fmt;
+
+ /*
+ * The output format is designed to give someone a fighting chance of
+ * figuring out which field is which:
+ * - level is in CAPS
+ * - cat is lower case and ends with comma
+ * - file normally has a .c extension and ends with a colon
+ * - line is integer and ends with a -
+ * - function is an identifier and ends with ()
+ * - message has a space before it unless it is on its own
+ */
+ if (fmt & (1 << LOGF_LEVEL))
+ printf("%s.", log_get_level_name(rec->level));
+ if (fmt & (1 << LOGF_CAT))
+ printf("%s,", log_get_cat_name(rec->cat));
+ if (fmt & (1 << LOGF_FILE))
+ printf("%s:", rec->file);
+ if (fmt & (1 << LOGF_LINE))
+ printf("%d-", rec->line);
+ if (fmt & (1 << LOGF_FUNC))
+ printf("%s()", rec->func);
+ if (fmt & (1 << LOGF_MSG))
+ printf("%s%s", fmt != (1 << LOGF_MSG) ? " " : "", rec->msg);
return 0;
}