diff --git a/lib/Kconfig b/lib/Kconfig index 897c8445b9..43089687c7 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -68,6 +68,11 @@ config CONSOLE help Support for various types of (debugging) consoles. +config CONSOLE_PREPEND_LOG_LEVEL + boolean "Prepend log level to messages" + default n + depends CONSOLE && EXPERT + choice prompt "Console log level" default CONSOLE_LOGLEVEL_8 diff --git a/lib/console.c b/lib/console.c index 3e9bd0e63c..08c192a1a7 100644 --- a/lib/console.c +++ b/lib/console.c @@ -132,12 +132,22 @@ int printk(int msg_level, const char *fmt, ...) va_list args; int i; +#ifdef CONFIG_CONSOLE_PREPEND_LOG_LEVEL + console_tx_byte('<', (void *)0); + console_tx_byte(msg_level + '0', (void *)0); + console_tx_byte('>', (void *)0); + + i = 3; + if (msg_level > console_loglevel()) { return 0; } +#else + i = 0; +#endif va_start(args, fmt); - i = vtxprintf(console_tx_byte, (void *)0, fmt, args); + i += vtxprintf(console_tx_byte, (void *)0, fmt, args); va_end(args); return i;