From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] common: console_common: output log messages to CONSOLE_STDERR
Date: Fri, 30 Sep 2022 17:41:45 +0200 [thread overview]
Message-ID: <20220930154145.754181-1-a.fatoum@pengutronix.de> (raw)
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@pengutronix.de>
---
common/console_common.c | 10 +++++-----
pbl/console.c | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
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
next reply other threads:[~2022-09-30 15:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 15:41 Ahmad Fatoum [this message]
2022-10-05 6:29 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220930154145.754181-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox