summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-30 17:41:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-05 08:29:29 +0200
commitf644f8d80a59407d44fcdd0ced7f3c956d24b849 (patch)
treee3e073ad074e5adab2610297b3fa8176d83e3d0a /common
parentaa3a70a50b99d317e81ecebe9704e8174c5b45c4 (diff)
downloadbarebox-f644f8d80a59407d44fcdd0ced7f3c956d24b849.tar.gz
barebox-f644f8d80a59407d44fcdd0ced7f3c956d24b849.tar.xz
common: console_common: output log messages to CONSOLE_STDERR
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> Link: https://lore.barebox.org/20220930154145.754181-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/console_common.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/common/console_common.c b/common/console_common.c
index 7bef74c543..ca1dad0f15 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);