mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] dmesg: restrict output to default log level by default
@ 2025-01-16 14:07 Ahmad Fatoum
  2025-01-21  7:59 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-01-16 14:07 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

When loglevel is set to debug, dmesg shows a torrent of messages,
because by default it shows all messages logged regardless of the
default log level.

To make it more convenient to use, change this to only print the same
messages that are synchronously printed by default.

Users wanting to see more can specify a log level via an extra argument
to the dmesg command.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/dmesg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/dmesg.c b/commands/dmesg.c
index 8a60f075076e..99675b6c2804 100644
--- a/commands/dmesg.c
+++ b/commands/dmesg.c
@@ -78,7 +78,7 @@ static int do_dmesg(int argc, char *argv[])
 {
 	int opt, ret, i;
 	int delete_buf = 0, emit = 0;
-	unsigned flags = 0, levels = 0;
+	unsigned flags = 0, levels = GENMASK(CONFIG_DEFAULT_LOGLEVEL, 0);
 	char *set = NULL;
 
 	while ((opt = getopt(argc, argv, "ctderl:n:")) > 0) {
-- 
2.39.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dmesg: restrict output to default log level by default
  2025-01-16 14:07 [PATCH] dmesg: restrict output to default log level by default Ahmad Fatoum
@ 2025-01-21  7:59 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-01-21  7:59 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Thu, Jan 16, 2025 at 03:07:52PM +0100, Ahmad Fatoum wrote:
> When loglevel is set to debug, dmesg shows a torrent of messages,
> because by default it shows all messages logged regardless of the
> default log level.
> 
> To make it more convenient to use, change this to only print the same
> messages that are synchronously printed by default.
> 
> Users wanting to see more can specify a log level via an extra argument
> to the dmesg command.

The default behaviour of the Linux command is to display all messages. I
would prefer the same behaviour for the barebox command. I think it's too
easy to forget that we could get more information by passing -l.

Also with this patch applied there is no easy way to restore the current
behaviour (unless CONFIG_DEFAULT_LOGLEVEL is 8 already). You would have
to do a

dmesg -l vdebug,debug,info,notice,warn,err,crit,alert,emerg

(I wonder why at least the Linux command doesn't support passing "all"
or "info+" as loglevel string)

Sascha

> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  commands/dmesg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/commands/dmesg.c b/commands/dmesg.c
> index 8a60f075076e..99675b6c2804 100644
> --- a/commands/dmesg.c
> +++ b/commands/dmesg.c
> @@ -78,7 +78,7 @@ static int do_dmesg(int argc, char *argv[])
>  {
>  	int opt, ret, i;
>  	int delete_buf = 0, emit = 0;
> -	unsigned flags = 0, levels = 0;
> +	unsigned flags = 0, levels = GENMASK(CONFIG_DEFAULT_LOGLEVEL, 0);
>  	char *set = NULL;
>  
>  	while ((opt = getopt(argc, argv, "ctderl:n:")) > 0) {
> -- 
> 2.39.5
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-21  8:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-16 14:07 [PATCH] dmesg: restrict output to default log level by default Ahmad Fatoum
2025-01-21  7:59 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox