From 8f0c2cdd13c1f6575cba4010f61c99fe5de9b1a9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 21 Jun 2016 09:59:09 -0600 Subject: [PATCH] SYSLOG: Change configuration selections to assure that one and only one SYSLOG device can be selected. Also add a check to assure that it is appropriate to use up_putc as the low-level syslog device. Adds CONFIG_SYSLOG_CONSOLE and CONFIG_SYSLOG_SERIAL_CONSOLE. --- arch/Kconfig | 1 + drivers/syslog/Kconfig | 76 ++++++++++++++++---------- drivers/syslog/syslog_channel.c | 2 +- drivers/syslog/syslog_consolechannel.c | 6 +- drivers/syslog/syslog_initialize.c | 2 +- 5 files changed, 52 insertions(+), 35 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index b3dd65f1bf..fa5bf48eda 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -58,6 +58,7 @@ config ARCH_SIM select ARCH_HAVE_TLS select ARCH_HAVE_TICKLESS select ARCH_HAVE_POWEROFF + select SERIAL_CONSOLE ---help--- Linux/Cywgin user-mode simulation. diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig index 7ba698fe93..6c6c8ed143 100644 --- a/drivers/syslog/Kconfig +++ b/drivers/syslog/Kconfig @@ -3,7 +3,7 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -comment "System Logging" +menu "System Logging" # Selected if the architecture has its own, built-in SYSLOGging enabled @@ -26,18 +26,6 @@ config RAMLOG details as needed to support logging. if RAMLOG -config RAMLOG_SYSLOG - bool "Use RAMLOG for SYSLOG" - default n - depends on SYSLOG && !ARCH_SYSLOG - ---help--- - Use the RAM logging device for the syslogging interface. If this feature - is enabled (along with SYSLOG), then all debug output (only) will be re-directed - to the circular buffer in RAM. This RAM log can be view from NSH using the - 'dmesg'command. - - Do not enable more than one SYSLOG device. - config RAMLOG_CONSOLE bool "Use RAMLOG for /dev/console" default n @@ -107,18 +95,57 @@ config SYSLOG_TIMESTAMP ---help--- Prepend timestamp to syslog message. -if SYSLOG +config SYSLOG_SERIAL_CONSOLE + bool + default n + +choice + prompt "System log device" + default SYSLOG_CONSOLE if DEV_CONSOLE + default SYSLOG_NONE if !DEV_CONSOLE + depends on !ARCH_SYSLOG config SYSLOG_CHAR - bool "System log character device support" - default y - depends on !ARCH_SYSLOG + bool "Log to a character device" ---help--- Enable the generic character device for the SYSLOG. The full path to the SYSLOG device is provided by SYSLOG_DEVPATH. A valid character device (or file) must exist at this path. It will by opened by syslog_initialize. - Do not enable more than one SYSLOG device. +config RAMLOG_SYSLOG + bool "Use RAMLOG for SYSLOG" + depends on RAMLOG && !ARCH_SYSLOG + ---help--- + Use the RAM logging device for the syslogging interface. If this + feature is enabled (along with SYSLOG), then all debug output (only) + will be re-directed to the circular buffer in RAM. This RAM log can + be viewed from NSH using the 'dmesg'command. + +config SYSLOG_CONSOLE + bool "Log to /dev/console" + depends on DEV_CONSOLE + select SYSLOG_SERIAL_CONSOLE if SERIAL_CONSOLE + ---help--- + Use the system console as a SYSLOG output device. + +config SYSLOG_NONE + bool "No SYSLOG device" + ---help--- + syslog() interfaces will be present, but all output will go to the + bit-bucket. + +endchoice + +config CONSOLE_SYSLOG + bool "Use SYSLOG for /dev/console" + default n + depends on DEV_CONSOLE && !SYSLOG_CONSOLE + ---help--- + Use the syslog logging device as a system console. If this feature is + enabled (along with DEV_CONSOLE), then all console output will be + re-directed to syslog output (syslog_putc). This is useful, for + example, if the only console is a Telnet console. Then in that case, + console output from non-Telnet threads will go to the syslog output. config SYSLOG_DEVPATH string "System log device" @@ -130,15 +157,4 @@ config SYSLOG_DEVPATH some other existing character device (or file) supported by the configuration (such as "/dev/ttyS1")/ -endif - -config CONSOLE_SYSLOG - bool "Use SYSLOG for /dev/console" - default n - depends on DEV_CONSOLE - ---help--- - Use the syslog logging device as a system console. If this feature is enabled - (along with DEV_CONSOLE), then all console output will be re-directed to syslog - output (syslog_putc). This is useful, for example, if the only console is a Telnet - console. Then in that case, console output from non-Telnet threads will go to - the syslog output. +endmenu # System logging diff --git a/drivers/syslog/syslog_channel.c b/drivers/syslog/syslog_channel.c index 20a0ca7f49..38eb801b08 100644 --- a/drivers/syslog/syslog_channel.c +++ b/drivers/syslog/syslog_channel.c @@ -73,7 +73,7 @@ static const struct syslog_channel_s g_default_channel = ramlog_putc, syslog_default_flush }; -#elif defined(CONFIG_ARCH_LOWPUTC) +#elif defined(CONFIG_SYSLOG_SERIAL_CONSOLE) && defined(CONFIG_ARCH_LOWPUTC) static const struct syslog_channel_s g_default_channel = { up_putc, diff --git a/drivers/syslog/syslog_consolechannel.c b/drivers/syslog/syslog_consolechannel.c index 16d7bab3b3..2d33478f79 100644 --- a/drivers/syslog/syslog_consolechannel.c +++ b/drivers/syslog/syslog_consolechannel.c @@ -44,14 +44,14 @@ #include "syslog.h" -#ifdef CONFIG_DEV_CONSOLE +#ifdef CONFIG_SYSLOG_CONSOLE /**************************************************************************** * Private Functions ****************************************************************************/ #undef HAVE_LOWPUTC -#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_ARCH_LOWPUTC) +#if defined(CONFIG_SYSLOG_SERIAL_CONSOLE) && defined(CONFIG_ARCH_LOWPUTC) # define HAVE_LOWPUTC 1 #endif @@ -153,4 +153,4 @@ int syslog_console_channel(void) return syslog_channel(&g_syslog_console_channel); } -#endif /* CONFIG_SYSLOG_CHAR */ +#endif /* CONFIG_SYSLOG_CONSOLE */ diff --git a/drivers/syslog/syslog_initialize.c b/drivers/syslog/syslog_initialize.c index 0cc7a0c688..08f12831ac 100644 --- a/drivers/syslog/syslog_initialize.c +++ b/drivers/syslog/syslog_initialize.c @@ -98,7 +98,7 @@ int syslog_initialize(enum syslog_init_e phase) ret = ramlog_syslog_channel(); } -#elif defined(CONFIG_DEV_CONSOLE) +#elif defined(CONFIG_SYSLOG_CONSOLE) if (phase == SYSLOG_INIT_LATE) { /* Use the console device as the SYSLOG device */