U-Boot logging

Simon Glass sjg at chromium.org
Thu Aug 17 00:01:50 CEST 2023


Hi Massimo,

On Tue, 15 Aug 2023 at 13:01, Massimo Pegorer
<massimo.pegorer+oss at gmail.com> wrote:
>
> Hi
>
> I had a trip into U-Boot logging and I am quite confused. I read the
> documentation at doc/develop/logging.rst and had a look at source code
> in log.h log.c printk.h Kconfig and other files, but the picture is
> still quite foggy and, let's say, 'complicated'.
>
> The documentation does not mention at all CONFIG_LOGLEVEL, but pr_xxx
> macros rely on its value (and then on log_xxx macros). While log_xxx
> definitions, instead, depends on CONFIG_LOG and other CONFIG_LOG_XXX
> values.
>
> It is not clear when/if pr_xxx and/or log/log_xxx should be used. Is
> any preferred and why? Is there a specific reason to keep both?
>
> Neither the constrains and relations between Kconfig variables are
> clear. CONFIG_LOGLEVEL and CONFIG_LOG are in different section
> of menuconfig: Console and Logging. The semantic is also a little
> bit different: for LOGLEVEL, values smaller than the console loglevel
> will be compiled in; for LOG_MAX_LEVEL, instead, any value higher
> than this will be ignored.
>
> The doc states that 'If CONFIG_LOG is not set, then no logging will
> be available'. But a few lines below 'If logging is disabled, the
> default behaviour is to output any message at level LOGL_INFO and
> below'. This sounds inconsistent to me.
>
> I see a lot of To Do tasks listed in logging.rst, like converting
> some other logging statements like debug() and error(). I wonder if
> something can be improved, and in case how: I could commit some of
> my spare time.

Yes, you are right and this is a good analysis. The todo you found [1]
is a good starting point, but anything you are able to contribute
would be valuable.

One point I'll mention is that we do what to support the kernel-style
logging so that code is easy to bring over. But those macros could be
converted to use U-Boot logging. Then the log-level problem you
mention could be resolved.

Regards,
Simon

[1] https://u-boot.readthedocs.io/en/latest/develop/logging.html#to-do


More information about the U-Boot mailing list