X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Flog_console.c;h=0b5b7089af846df60485b8fef2ad2d05be3a5efa;hb=9ca8388059de8f10e035fbdcaa418ec3caeb0599;hp=5af73bd8be4f2c8f5c3abc6a9d7ba25ba83ea12e;hpb=76cc372879e2f2f0467e8a3875f097d189647793;p=u-boot diff --git a/common/log_console.c b/common/log_console.c index 5af73bd8be..0b5b7089af 100644 --- a/common/log_console.c +++ b/common/log_console.c @@ -1,18 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Logging support * * Copyright (c) 2017 Google, Inc * Written by Simon Glass - * - * SPDX-License-Identifier: GPL-2.0+ */ #include #include +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; }