Re: [PATCH 4/5] dmesg: implement dmesg -n

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
> ---
>  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
> 
> 
> 




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux