log: Allow padding of the function name

At present when function names are logged, the output is a little hard to
read since every function is a different length. Add a way to pad the
names so that the log messages line up vertically. This doesn't work if
the function name is very long, but it makes a big difference in most
cases.

Use 20 characters as a default since this covers the vast majority of
functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2021-07-05 16:33:00 -06:00
parent 96f37b092f
commit 72fa1ad8d9
3 changed files with 18 additions and 8 deletions

View File

@@ -38,7 +38,7 @@ static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
if (fmt & BIT(LOGF_LINE))
printf("%d-", rec->line);
if (fmt & BIT(LOGF_FUNC))
printf("%s()", rec->func);
printf("%*s()", CONFIG_LOGF_FUNC_PAD, rec->func);
}
if (fmt & BIT(LOGF_MSG))
printf("%s%s", add_space ? " " : "", rec->msg);