summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2023-06-12 14:06:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-06-13 08:42:08 +0200
commit7df3c4fc6ead90893ca4baa274761756fb7f8593 (patch)
treea425abe613842301b2cb2550e7e87809d95d3f3d /commands
parent8db1f82c8aed218477b2cdf0e4b2c7e0122116cd (diff)
downloadbarebox-7df3c4fc6ead90893ca4baa274761756fb7f8593.tar.gz
barebox-7df3c4fc6ead90893ca4baa274761756fb7f8593.tar.xz
dmesg: implement dmesg -n
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>
Diffstat (limited to 'commands')
-rw-r--r--commands/dmesg.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/commands/dmesg.c b/commands/dmesg.c
index 4cd88e3189..a25e3265dd 100644
--- a/commands/dmesg.c
+++ b/commands/dmesg.c
@@ -79,8 +79,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;
@@ -102,11 +103,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;
+
+ return 0;
+ }
+
if (emit) {
char *buf;
int len = 0;
@@ -147,6 +162,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