From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/15] sandbox: Add a flag to set the default log level
Date: Mon, 1 Oct 2018 11:55:11 -0600 [thread overview]
Message-ID: <20181001175520.239554-7-sjg@chromium.org> (raw)
In-Reply-To: <20181001175520.239554-1-sjg@chromium.org>
It is useful to be able to set the default log level from the command line
when running sandbox. Add a new -L command-line flag for this. The log
level is set using the enum log_level_t in log.h. At present a number must
be specified, e.g. -L7 for debug.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/sandbox/cpu/start.c | 13 +++++++++++++
arch/sandbox/include/asm/state.h | 1 +
common/log.c | 3 ++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 2251ec4c53f..ab5007c7b35 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -282,6 +282,16 @@ static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state,
}
SANDBOX_CMDLINE_OPT(show_of_platdata, 0, "Show of-platdata in SPL");
+static int sandbox_cmdline_cb_log_level(struct sandbox_state *state,
+ const char *arg)
+{
+ state->default_log_level = simple_strtol(arg, NULL, 10);
+
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(log_level, 'L', 1,
+ "Set log level (0=panic, 7=debug)");
+
int board_run_command(const char *cmdline)
{
printf("## Commands are disabled. Please enable CONFIG_CMDLINE.\n");
@@ -331,6 +341,9 @@ int main(int argc, char *argv[])
gd = &data;
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
gd->malloc_base = CONFIG_MALLOC_F_ADDR;
+#endif
+#if CONFIG_IS_ENABLED(LOG)
+ gd->default_log_level = state->default_log_level;
#endif
setup_ram_buf(state);
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 4e4c71b8062..d1baba1c3ae 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -90,6 +90,7 @@ struct sandbox_state {
bool skip_delays; /* Ignore any time delays (for test) */
bool show_test_output; /* Don't suppress stdout in tests */
bool show_of_platdata; /* Show of-platdata in SPL */
+ int default_log_level; /* Default log level for sandbox */
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
diff --git a/common/log.c b/common/log.c
index 59869cd29da..ec14644516c 100644
--- a/common/log.c
+++ b/common/log.c
@@ -315,7 +315,8 @@ int log_init(void)
drv++;
}
gd->flags |= GD_FLG_LOG_READY;
- gd->default_log_level = LOGL_INFO;
+ if (!gd->default_log_level)
+ gd->default_log_level = LOGL_INFO;
gd->log_fmt = LOGF_DEFAULT;
return 0;
--
2.19.0.605.g01d371f741-goog
next prev parent reply other threads:[~2018-10-01 17:55 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 17:55 [U-Boot] [PATCH 00/15] sandbox: Add support for TPL and other improvements Simon Glass
2018-10-01 17:55 ` [U-Boot] [PATCH 01/15] log: Add helpers for common log levels Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 02/15] sandbox: Support file truncation with os_open() Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 03/15] sandbox: Add a way to write data to the host filesystem Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 04/15] sandbox: spi: Drop command-line SPI option Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 05/15] sandbox: Support booting from TPL to SPL Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` Simon Glass [this message]
2018-10-09 23:51 ` [U-Boot] [PATCH 06/15] sandbox: Add a flag to set the default log level sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 07/15] sandbox: Remove the old memory file later Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 08/15] sandbox: spi: Add more logging Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 09/15] sandbox: video: Speed up video output Simon Glass
2018-10-01 19:20 ` Anatolij Gustschin
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 10/15] sandbox: Add a debug UART Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 11/15] serial: sandbox: Allow serial output without device tree Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 12/15] sandbox: tpm: Tidy up enums and return values Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 13/15] sandbox: tpm: Enhance to support the latest Chromium OS Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 14/15] dm: spi: Clean up detection of sandbox SPI emulator Simon Glass
2018-10-09 23:51 ` sjg at google.com
2018-10-01 17:55 ` [U-Boot] [PATCH 15/15] sandbox: Restore blocking I/O on exit Simon Glass
2018-10-09 23:51 ` sjg at google.com
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=20181001175520.239554-7-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.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