diff mbox series

[U-Boot,3/9] log: Add control over log formatting

Message ID 20171228201423.128338-4-sjg@chromium.org
State Accepted
Commit 3b73e8d067fb7cb504bed2018583980a3cd3f4bc
Delegated to: Simon Glass
Headers show
Series log: Support control over the log output format | expand

Commit Message

Simon Glass Dec. 28, 2017, 8:14 p.m. UTC
It is useful to be able to control the output format of log records on the
console. As a starting point, add definitions for controlling which
elements of the log record are displayed. Use function and message as the
default, since these are the most useful fields.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/log.c                      |  1 +
 include/asm-generic/global_data.h |  1 +
 include/log.h                     | 14 ++++++++++++++
 3 files changed, 16 insertions(+)

Comments

Simon Glass Jan. 26, 2018, 9:42 p.m. UTC | #1
On 28 December 2017 at 13:14, Simon Glass <sjg@chromium.org> wrote:
> It is useful to be able to control the output format of log records on the
> console. As a starting point, add definitions for controlling which
> elements of the log record are displayed. Use function and message as the
> default, since these are the most useful fields.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/log.c                      |  1 +
>  include/asm-generic/global_data.h |  1 +
>  include/log.h                     | 14 ++++++++++++++
>  3 files changed, 16 insertions(+)

Applied to u-boot-dm.
diff mbox series

Patch

diff --git a/common/log.c b/common/log.c
index 5761a2ce76..7559d74e90 100644
--- a/common/log.c
+++ b/common/log.c
@@ -307,6 +307,7 @@  int log_init(void)
 	}
 	gd->flags |= GD_FLG_LOG_READY;
 	gd->default_log_level = LOGL_INFO;
+	gd->log_fmt = LOGF_DEFAULT;
 
 	return 0;
 }
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 73e036d6fd..f1c21dfd20 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -118,6 +118,7 @@  typedef struct global_data {
 	int log_drop_count;		/* Number of dropped log messages */
 	int default_log_level;		/* For devices with no filters */
 	struct list_head log_head;	/* List of struct log_device */
+	int log_fmt;			/* Mask containing log format info */
 #endif
 } gd_t;
 #endif
diff --git a/include/log.h b/include/log.h
index 5133213acf..828919a409 100644
--- a/include/log.h
+++ b/include/log.h
@@ -291,6 +291,20 @@  const char *log_get_level_name(enum log_level_t level);
  */
 enum log_level_t log_get_level_by_name(const char *name);
 
+/* Log format flags (bit numbers) for gd->log_fmt. See log_fmt_chars */
+enum log_fmt {
+	LOGF_CAT	= 0,
+	LOGF_LEVEL,
+	LOGF_FILE,
+	LOGF_LINE,
+	LOGF_FUNC,
+	LOGF_MSG,
+
+	LOGF_COUNT,
+	LOGF_DEFAULT = (1 << LOGF_FUNC) | (1 << LOGF_MSG),
+	LOGF_ALL = 0x3f,
+};
+
 /* Handle the 'log test' command */
 int do_log_test(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);