]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
log: Add a console driver
authorSimon Glass <sjg@chromium.org>
Mon, 4 Dec 2017 20:48:25 +0000 (13:48 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 7 Dec 2017 20:17:00 +0000 (15:17 -0500)
It is useful to display log messages on the console. Add a simple driver
to handle this.

Note that this driver outputs to the console, which may be serial or
video. It does not specifically select serial output.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
common/Kconfig
common/Makefile
common/log_console.c [new file with mode: 0644]

index 9747443feb29a9e1dbd57050553fd35fe5313ad9..1b157e47c3deb4b465868b2d462ebb8597baffd5 100644 (file)
@@ -474,6 +474,26 @@ config SPL_LOG_MAX_LEVEL
            6 - detail
            7 - debug
 
+config LOG_CONSOLE
+       bool "Allow log output to the console"
+       depends on LOG
+       default y
+       help
+         Enables a log driver which writes log records to the console.
+         Generally the console is the serial port or LCD display. Only the
+         log message is shown - other details like level, category, file and
+         line number are omitted.
+
+config LOG_SPL_CONSOLE
+       bool "Allow log output to the console in SPL"
+       depends on LOG_SPL
+       default y
+       help
+         Enables a log driver which writes log records to the console.
+         Generally the console is the serial port or LCD display. Only the
+         log message is shown - other details like level, category, file and
+         line number are omitted.
+
 endmenu
 
 config DEFAULT_FDT_FILE
index f4b632761fa16c8097975efb9ff54274c4344c03..14166209fe4c5d7202f00eeb6a1936da1a78478b 100644 (file)
@@ -129,5 +129,6 @@ obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
 obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-$(CONFIG_$(SPL_)LOG) += log.o
+obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
 obj-y += s_record.o
 obj-y += xyzModem.o
diff --git a/common/log_console.c b/common/log_console.c
new file mode 100644 (file)
index 0000000..5af73bd
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Logging support
+ *
+ * Copyright (c) 2017 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <log.h>
+
+static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
+{
+       puts(rec->msg);
+
+       return 0;
+}
+
+LOG_DRIVER(console) = {
+       .name   = "console",
+       .emit   = log_console_emit,
+};