summaryrefslogtreecommitdiffstats
path: root/common/console_common.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-02-07 13:47:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-29 12:15:40 +0200
commit666f12e0c19a19f4431e05f6e5b37e657a62038f (patch)
treeba5a20de0da52c1651184e080440462f97c8305a /common/console_common.c
parent61694c93cd9e47e2ea72d9095817040a4c0c2cee (diff)
downloadbarebox-666f12e0c19a19f4431e05f6e5b37e657a62038f.tar.gz
barebox-666f12e0c19a19f4431e05f6e5b37e657a62038f.tar.xz
introduce runtime loglevel
With this the verbosity of barebox can be controlled during runtime using the 'loglevel' globalvar. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console_common.c')
-rw-r--r--common/console_common.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/common/console_common.c b/common/console_common.c
index d1b823ef8a..18b76766d6 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -57,6 +57,33 @@ void console_allow_input(bool val)
console_input_allow = val;
}
+int barebox_loglevel = CONFIG_DEFAULT_LOGLEVEL;
+
+int pr_print(int level, const char *fmt, ...)
+{
+ va_list args;
+ uint i;
+ char printbuffer[CFG_PBSIZE];
+
+ if (level > barebox_loglevel)
+ return 0;
+
+ va_start(args, fmt);
+ i = vsprintf(printbuffer, fmt, args);
+ va_end(args);
+
+ /* Print the string */
+ puts(printbuffer);
+
+ return i;
+}
+
+static int loglevel_init(void)
+{
+ return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d");
+}
+device_initcall(loglevel_init);
+
int printf(const char *fmt, ...)
{
va_list args;