mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/5] dmesg: implement dmesg -n
Date: Tue, 13 Jun 2023 08:45:18 +0200	[thread overview]
Message-ID: <20230613064518.up4nhv3t2iqcya4s@pengutronix.de> (raw)
In-Reply-To: <20230612123232.3071957-5-s.hauer@pengutronix.de>

Hi Sascha,

On 23-06-12, Sascha Hauer wrote:
> Under Linux dmesg -n can be used to set the console loglevel. Implement
> the same for barebox.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  commands/dmesg.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/commands/dmesg.c b/commands/dmesg.c
> index 00e5a159e0..953bdb2068 100644
> --- a/commands/dmesg.c
> +++ b/commands/dmesg.c
> @@ -77,8 +77,9 @@ static int do_dmesg(int argc, char *argv[])
>  	int opt, i;
>  	int delete_buf = 0, emit = 0;
>  	unsigned flags = 0, levels = 0;
> +	char *set = NULL;
>  
> -	while ((opt = getopt(argc, argv, "ctderl:")) > 0) {
> +	while ((opt = getopt(argc, argv, "ctderl:n:")) > 0) {
>  		switch (opt) {
>  		case 'c':
>  			delete_buf = 1;
> @@ -100,11 +101,25 @@ static int do_dmesg(int argc, char *argv[])
>  		case 'r':
>  			flags |= BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME;
>  			break;
> +		case 'n':
> +			set = optarg;
> +			break;
>  		default:
>  			return COMMAND_ERROR_USAGE;
>  		}
>  	}
>  
> +	if (set) {
> +		int level = str_to_loglevel(set);
> +
> +		if (level < 0)
> +			return COMMAND_ERROR;
> +
> +		barebox_loglevel = level;

Not really realted to this patch, but should we make 'barebox_loglevel'
private and use a setter like console_set_loglevel()? Asking because
console_common.c is the currently the only upstream user.

Regards,
  Marco

> +
> +		return 0;
> +	}
> +
>  	if (emit) {
>  		char *buf;
>  		int len = 0;
> @@ -145,6 +160,7 @@ BAREBOX_CMD_HELP_OPT ("-c",		"Delete messages after printing them")
>  BAREBOX_CMD_HELP_OPT ("-d",		"Show a time delta to the last message")
>  BAREBOX_CMD_HELP_OPT ("-e <msg>",	"Emit a log message")
>  BAREBOX_CMD_HELP_OPT ("-l <vdebug|debug|info|notice|warn|err|crit|alert|emerg>", "Restrict output to the given (comma-separated) list of levels")
> +BAREBOX_CMD_HELP_OPT ("-n <loglevel>", "Set level at which printing of messages is done to the console")
>  BAREBOX_CMD_HELP_OPT ("-r",		"Print timestamp and log-level prefixes.")
>  BAREBOX_CMD_HELP_OPT ("-t",		"Show timestamp informations")
>  BAREBOX_CMD_HELP_END
> -- 
> 2.39.2
> 
> 
> 



  reply	other threads:[~2023-06-13  6:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 12:32 [PATCH 0/5] " Sascha Hauer
2023-06-12 12:32 ` [PATCH 1/5] dmesg: factor out str_to_loglevel() Sascha Hauer
2023-06-13  6:41   ` Marco Felsch
2023-06-12 12:32 ` [PATCH 2/5] dmesg: error out on unknown loglevels Sascha Hauer
2023-06-13  6:34   ` Marco Felsch
2023-06-13  6:49     ` Sascha Hauer
2023-06-13  6:57       ` Marco Felsch
2023-06-12 12:32 ` [PATCH 3/5] dmesg: allow loglevels specified as numbers Sascha Hauer
2023-06-13  6:41   ` Marco Felsch
2023-06-12 12:32 ` [PATCH 4/5] dmesg: implement dmesg -n Sascha Hauer
2023-06-13  6:45   ` Marco Felsch [this message]
2023-06-13  6:54     ` Sascha Hauer
2023-06-12 12:32 ` [PATCH 5/5] dmesg: udpate help Sascha Hauer
2023-06-13  6:40   ` Marco Felsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230613064518.up4nhv3t2iqcya4s@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox