aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-20 20:10:53 -0700
committerTom Rini <trini@konsulko.com>2021-03-12 17:41:35 -0500
commit9ad7a6c25c7142a46fe4b811c13bc3280c4bb27f (patch)
tree3ad69164919285a4f79ecd37355df16db6945f6a /doc
parent79d5983b61e41d5c586489b03e75a75961d31041 (diff)
downloadu-boot-9ad7a6c25c7142a46fe4b811c13bc3280c4bb27f.zip
u-boot-9ad7a6c25c7142a46fe4b811c13bc3280c4bb27f.tar.gz
u-boot-9ad7a6c25c7142a46fe4b811c13bc3280c4bb27f.tar.bz2
log: Handle line continuation
When multiple log() calls are used which don't end in newline, the log prefix is prepended multiple times in the same line. This makes the output look strange. Fix this by detecting when the previous log record did not end in newline. In that case, setting a flag. Drop the unused BUFFSIZE in the test while we are here. As an example implementation, update log_console to check the flag and produce the expected output. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'doc')
-rw-r--r--doc/develop/logging.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 60c18c5..622ad6a 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -96,6 +96,22 @@ Also debug() and error() will generate log records - these use LOG_CATEGORY
as the category, so you should #define this right at the top of the source
file to ensure the category is correct.
+Generally each log format_string ends with a newline. If it does not, then the
+next log statement will have the LOGRECF_CONT flag set. This can be used to
+continue the statement on the same line as the previous one without emitting
+new header information (such as category/level). This behaviour is implemented
+with log_console. Here is an example that prints a list all on one line with
+the tags at the start:
+
+.. code-block:: c
+
+ log_debug("Here is a list:");
+ for (i = 0; i < count; i++)
+ log_debug(" item %d", i);
+ log_debug("\n");
+
+Also see the special category LOGL_CONT and level LOGC_CONT.
+
You can also define CONFIG_LOG_ERROR_RETURN to enable the log_ret() macro. This
can be used whenever your function returns an error value: