From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/4] sandbox: add support for --loglevel option
Date: Mon, 16 Dec 2024 12:36:37 +0100 [thread overview]
Message-ID: <20241216113640.403845-1-a.fatoum@pengutronix.de> (raw)
To simplify debugging, let's allow the user to override the default log
level from the command line.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/os/common.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index d8bb345614ac..7067c94d9b45 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -20,6 +20,7 @@
* files here...
*/
#define _GNU_SOURCE
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -46,6 +47,12 @@
#include <mach/linux.h>
#include <mach/hostfile.h>
+#ifdef CONFIG_CONSOLE_NONE
+int __attribute__((unused)) barebox_loglevel;
+#else
+extern int barebox_loglevel;
+#endif
+
#define DELETED_OFFSET (sizeof(" (deleted)") - 1)
void __sanitizer_set_death_callback(void (*callback)(void));
@@ -506,6 +513,8 @@ const char *barebox_cmdline_get(void)
static void print_usage(const char*);
+#define OPT_LOGLEVEL (CHAR_MAX + 1)
+
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"malloc", 1, 0, 'm'},
@@ -518,6 +527,9 @@ static struct option long_options[] = {
{"stdinout", 1, 0, 'B'},
{"xres", 1, 0, 'x'},
{"yres", 1, 0, 'y'},
+#ifndef CONFIG_CONSOLE_NONE
+ {"loglevel", 1, 0, OPT_LOGLEVEL},
+#endif
{0, 0, 0, 0},
};
@@ -528,7 +540,7 @@ int main(int argc, char *argv[])
void *ram;
int opt, ret, fd, fd2;
int malloc_size = CONFIG_MALLOC_SIZE;
- int fdno = 0, envno = 0, option_index = 0;
+ int loglevel = -1, fdno = 0, envno = 0, option_index = 0;
char *new_cmdline;
char *aux;
@@ -551,6 +563,9 @@ int main(int argc, char *argv[])
case 'm':
malloc_size = strtoul(optarg, NULL, 0);
break;
+ case OPT_LOGLEVEL:
+ loglevel = strtoul(optarg, NULL, 0);
+ break;
case 'i':
break;
case 'c':
@@ -665,6 +680,10 @@ int main(int argc, char *argv[])
barebox_register_console(fileno(stdin), fileno(stdout));
rawmode();
+
+ if (loglevel >= 0)
+ barebox_loglevel = loglevel;
+
start_barebox();
/* never reached */
@@ -705,7 +724,19 @@ static void print_usage(const char *prgname)
" stdin and stdout. <filein> and <fileout> can be regular\n"
" files or FIFOs.\n"
" -x, --xres=<res> SDL width.\n"
-" -y, --yres=<res> SDL height.\n",
- prgname
+" -y, --yres=<res> SDL height.\n"
+#ifndef CONFIG_CONSOLE_NONE
+" --loglevel=<num> Default log level to use, where <num> is one of:\n"
+" 0 system is unusable (emerg)\n"
+" 1 action must be taken immediately (alert)\n"
+" 2 critical conditions (crit)\n"
+" 3 error conditions (err)\n"
+" 4 warning conditions (warn)\n"
+" 5 normal but significant condition (notice)\n"
+" 6 informational (info)\n"
+" 7 debug-level messages (debug)\n"
+" 8 verbose debug messages (vdebug)\n"
+#endif
+ , prgname
);
}
--
2.39.5
next reply other threads:[~2024-12-16 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 11:36 Ahmad Fatoum [this message]
2024-12-16 11:36 ` [PATCH 2/4] sandbox: add support for architecture-specific debug options Ahmad Fatoum
2024-12-16 11:36 ` [PATCH 3/4] sandbox: move CONFIG_ASAN to architecture Kconfig Ahmad Fatoum
2024-12-16 11:36 ` [PATCH 4/4] startup: set barebox_main in data section Ahmad Fatoum
2024-12-20 9:04 ` [PATCH 1/4] sandbox: add support for --loglevel option Sascha Hauer
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=20241216113640.403845-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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