[PATCH] common: console_common: output log messages to CONSOLE_STDERR
Sascha Hauer
sha at pengutronix.de
Tue Oct 4 23:29:40 PDT 2022
On Fri, Sep 30, 2022 at 05:41:45PM +0200, Ahmad Fatoum wrote:
> Like U-Boot, barebox has two standard output streams:
> CONSOLE_STDOUT and CONSOLE_STDERR in addition to the input stream
> CONSOLE_STDIN.
>
> From a consumer view, the console.active device parameter allows
> restricting which of these streams interact with a given console.
>
> From a provider view, only CONSOLE_STDOUT is ever used. dputs
> dputc allow passing in CONSOLE_STDERR instead, but nothing in-tree
> does so.
>
> Change this by having all log messages (e.g. pr_debug or dev_err)
> go to CONSOLE_STDERR. For nearly all systems that just use the default
> of console.active="ioe" or "oe", there is no difference. But now
> systems that use either "o" or "e" can use different console
> devices for barebox log messages and for standard output by commands.
> This is especially useful to debug interactive applications like edit
> or for monitoring barebox debug messages during execution of payloads
> when barebox acts as EFI loader.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> common/console_common.c | 10 +++++-----
> pbl/console.c | 6 +++---
> 2 files changed, 8 insertions(+), 8 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/common/console_common.c b/common/console_common.c
> index 7bef74c54391..ca1dad0f159f 100644
> --- a/common/console_common.c
> +++ b/common/console_common.c
> @@ -68,7 +68,7 @@ void log_clean(unsigned int limit)
> }
> }
>
> -static void print_colored_log_level(const int level)
> +static void print_colored_log_level(unsigned int ch, const int level)
> {
> if (!console_allow_color())
> return;
> @@ -77,7 +77,7 @@ static void print_colored_log_level(const int level)
> if (!colored_log_level[level])
> return;
>
> - puts(colored_log_level[level]);
> + console_puts(ch, colored_log_level[level]);
> }
>
> static void pr_puts(int level, const char *str)
> @@ -112,8 +112,8 @@ nolog:
> if (level > barebox_loglevel)
> return;
>
> - print_colored_log_level(level);
> - puts(str);
> + print_colored_log_level(CONSOLE_STDERR, level);
> + console_puts(CONSOLE_STDERR, str);
> }
>
> int pr_print(int level, const char *fmt, ...)
> @@ -217,7 +217,7 @@ void log_print(unsigned flags, unsigned levels)
>
> if (!(flags & (BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME
> | BAREBOX_LOG_DIFF_TIME)))
> - print_colored_log_level(log->level);
> + print_colored_log_level(CONSOLE_STDOUT, log->level);
>
> if (flags & BAREBOX_LOG_PRINT_RAW)
> printf("<%i>", log->level);
> diff --git a/pbl/console.c b/pbl/console.c
> index fc8e8cdf1383..a147e2a19e49 100644
> --- a/pbl/console.c
> +++ b/pbl/console.c
> @@ -39,9 +39,9 @@ int console_puts(unsigned int ch, const char *str)
>
> while (*str) {
> if (*str == '\n')
> - console_putc(CONSOLE_STDOUT, '\r');
> + console_putc(ch, '\r');
>
> - console_putc(CONSOLE_STDOUT, *str);
> + console_putc(ch, *str);
> str++;
> n++;
> }
> @@ -74,7 +74,7 @@ int pr_print(int level, const char *fmt, ...)
> i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args);
> va_end(args);
>
> - console_puts(CONSOLE_STDOUT, printbuffer);
> + console_puts(CONSOLE_STDERR, printbuffer);
>
> return i;
> }
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list