summaryrefslogtreecommitdiffstats
path: root/common/console_common.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-02-20 08:20:20 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-02-22 08:28:46 +0100
commit7e879bd678fa1ac8b1b0bd4e7b9c845b0e967da2 (patch)
tree6a7004cc79bda34e3e46bcb53292247d13849913 /common/console_common.c
parente18cc5b7e9ce0ac71f0e00f166ca2e2afcc3f466 (diff)
downloadbarebox-7e879bd678fa1ac8b1b0bd4e7b9c845b0e967da2.tar.gz
console: move global.allow_color handling to C code
We have global.allow_color, but this is limited to the environment only. Move creation and handling of this variable to C code so that we can add support for colored output to commands/console controlled by the same variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console_common.c')
-rw-r--r--common/console_common.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/common/console_common.c b/common/console_common.c
index d051458..0202345 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -145,15 +145,28 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...)
return ret;
}
-static int loglevel_init(void)
+#ifdef CONFIG_CONSOLE_ALLOW_COLOR
+static unsigned int __console_allow_color = 1;
+#else
+static unsigned int __console_allow_color = 0;
+#endif
+
+bool console_allow_color(void)
+{
+ return __console_allow_color;
+}
+
+static int console_common_init(void)
{
if (IS_ENABLED(CONFIG_LOGBUF))
globalvar_add_simple_int("log_max_messages",
&barebox_log_max_messages, "%d");
+ globalvar_add_simple_bool("allow_color", &__console_allow_color);
+
return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d");
}
-device_initcall(loglevel_init);
+device_initcall(console_common_init);
void log_print(unsigned flags)
{