diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 605824ddb4f..68c766773d9 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1383,7 +1383,6 @@ config DEBUG_SECUREFAULT config ARM_SEMIHOSTING_SYSLOG bool "Semihosting SYSLOG support" - select ARCH_SYSLOG select SYSLOG_REGISTER ---help--- Enable hooks to support semihosting syslog output. diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig index 97022b294f2..c387d87b11c 100644 --- a/arch/arm/src/armv7-m/Kconfig +++ b/arch/arm/src/armv7-m/Kconfig @@ -128,7 +128,6 @@ config ARMV7M_STACKCHECK_BREAKPOINT config ARMV7M_ITMSYSLOG bool "ITM SYSLOG support" default n - select ARCH_SYSLOG ---help--- Enable hooks to support ITM syslog output. This requires additional MCU support in order to be used. See arch/arm/src/armv7-m/itm_syslog.h diff --git a/arch/arm/src/armv8-m/Kconfig b/arch/arm/src/armv8-m/Kconfig index fc207a48479..317fc8581df 100644 --- a/arch/arm/src/armv8-m/Kconfig +++ b/arch/arm/src/armv8-m/Kconfig @@ -127,7 +127,6 @@ config ARMV8M_STACKCHECK_BREAKPOINT config ARMV8M_ITMSYSLOG bool "ITM SYSLOG support" default n - select ARCH_SYSLOG ---help--- Enable hooks to support ITM syslog output. This requires additional MCU support in order to be used. See arch/arm/src/armv8-m/itm_syslog.h diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig index 32016eb2e27..db30c70e070 100644 --- a/drivers/syslog/Kconfig +++ b/drivers/syslog/Kconfig @@ -5,16 +5,48 @@ menu "System Logging" -# Selected if the architecture has its own, built-in SYSLOGging enabled +# Selected if the architecture has its own, built-in SYSLOG enabled + +choice + prompt "System logging" + default SYSLOG + +config SYSLOG + bool "Enable system logging" + ---help--- + Enables the SYSLOG interface. config ARCH_SYSLOG - bool + bool "Architecture-specific SYSLOG support" + ---help--- + Architecture-specific SYSLOG support + +config SYSLOG_TO_SCHED_NOTE + bool "SYSLOG redirected to sched_note" + depends on SCHED_INSTRUMENTATION_DUMP + ---help--- + If this option is enabled, syslog will be redirected to sched_note, + It uses the sched_note_printf macro to replace syslog +endchoice + +config SYSLOG_CHARDEV + bool "SYSLOG character device" default n + ---help--- + Enables support for a simple character driver at /dev/log whose + write() method will transfer data to the SYSLOG device. This can be + useful if, for example, you want to redirect the output of a program + to the SYSLOG. + + NOTE that unlike other syslog output, this data is unformatted raw + byte output with no time-stamping or any other SYSLOG features + supported. config SYSLOG_DEFAULT_MASK hex "syslog mask default value" default 0xff +if SYSLOG comment "SYSLOG options" config SYSLOG_MAX_CHANNELS @@ -361,19 +393,6 @@ config CONSOLE_SYSLOG 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_CHARDEV - bool "SYSLOG character device" - default n - ---help--- - Enables support for a simple character driver at /dev/log whose - write() method will transfer data to the SYSLOG device. This can be - useful if, for example, you want to redirect the output of a program - to the SYSLOG. - - NOTE that unlike other syslog output, this data is unformatted raw - byte output with no time-stamping or any other SYSLOG features - supported. - config SYSLOG_IOCTL bool "SYSLOG IOCTL support" default n @@ -388,4 +407,5 @@ config SYSLOG_REGISTER ---help--- This option will support register the syslog channel dynamically. +endif # SYSLOG endmenu # System logging diff --git a/drivers/syslog/Make.defs b/drivers/syslog/Make.defs index 3c728d4a3aa..db6dd00002a 100644 --- a/drivers/syslog/Make.defs +++ b/drivers/syslog/Make.defs @@ -21,14 +21,16 @@ ############################################################################ # Include SYSLOG Infrastructure +ifeq ($(CONFIG_SYSLOG),y) CSRCS += vsyslog.c syslog_channel.c syslog_putc.c CSRCS += syslog_write.c syslog_flush.c +endif ifeq ($(CONFIG_SYSLOG_INTBUFFER),y) CSRCS += syslog_intbuffer.c endif -ifneq ($(CONFIG_ARCH_SYSLOG),y) +ifeq ($(CONFIG_SYSLOG),y) CSRCS += syslog_initialize.c endif @@ -48,7 +50,9 @@ endif # System logging to a character device (or file) ifneq ($(CONFIG_SYSLOG_CONSOLE)$(CONFIG_SYSLOG_CHAR)$(CONFIG_SYSLOG_FILE),) -CSRCS += syslog_device.c + ifeq ($(CONFIG_SYSLOG),y) + CSRCS += syslog_device.c + endif endif ifeq ($(CONFIG_SYSLOG_CHAR),y) diff --git a/drivers/syslog/syslog.h b/drivers/syslog/syslog.h index e86210353a6..486d702aeeb 100644 --- a/drivers/syslog/syslog.h +++ b/drivers/syslog/syslog.h @@ -47,6 +47,7 @@ extern "C" * g_default_channel. */ +#ifdef CONFIG_SYSLOG EXTERN FAR syslog_channel_t * #ifndef CONFIG_SYSLOG_REGISTER const @@ -227,6 +228,7 @@ int syslog_add_intbuffer(int ch); #ifdef CONFIG_SYSLOG_INTBUFFER int syslog_flush_intbuffer(bool force); #endif +#endif /* CONFIG_SYSLOG */ #undef EXTERN #ifdef __cplusplus diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index 9ea0757bacc..959efc6bbf9 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -281,6 +281,15 @@ enum note_type_e enum note_tag_e { NOTE_TAG_ALWAYS = 0, + NOTE_TAG_LOG, + NOTE_TAG_LOG_EMERG = NOTE_TAG_LOG, + NOTE_TAG_LOG_ALERT, + NOTE_TAG_LOG_CRIT, + NOTE_TAG_LOG_ERR, + NOTE_TAG_LOG_WARNING, + NOTE_TAG_LOG_NOTICE, + NOTE_TAG_LOG_INFO, + NOTE_TAG_LOG_DEBUG, NOTE_TAG_APP, NOTE_TAG_ARCH, NOTE_TAG_AUDIO, diff --git a/include/nuttx/syslog/syslog.h b/include/nuttx/syslog/syslog.h index b2b33dab993..833b104b38c 100644 --- a/include/nuttx/syslog/syslog.h +++ b/include/nuttx/syslog/syslog.h @@ -232,7 +232,7 @@ int syslog_channel_unregister(FAR syslog_channel_t *channel); * ****************************************************************************/ -#ifndef CONFIG_ARCH_SYSLOG +#ifdef CONFIG_SYSLOG int syslog_initialize(void); #else # define syslog_initialize() @@ -365,7 +365,11 @@ ssize_t syslog_write(FAR const char *buffer, size_t buflen); * ****************************************************************************/ +#ifdef CONFIG_SYSLOG int syslog_flush(void); +#else +# define syslog_flush() +#endif /**************************************************************************** * Name: nx_vsyslog @@ -380,7 +384,9 @@ int syslog_flush(void); * ****************************************************************************/ +#ifdef CONFIG_SYSLOG int nx_vsyslog(int priority, FAR const IPTR char *src, FAR va_list *ap); +#endif #undef EXTERN #ifdef __cplusplus diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h index f59bc65fac6..8bdca9d370b 100644 --- a/include/sys/syscall_lookup.h +++ b/include/sys/syscall_lookup.h @@ -183,7 +183,9 @@ SYSCALL_LOOKUP(clock_settime, 2) /* System logging */ +#ifdef CONFIG_SYSLOG SYSCALL_LOOKUP(nx_vsyslog, 3) +#endif /* The following are defined if either file or socket descriptor are * enabled. diff --git a/include/syslog.h b/include/syslog.h index d7e54e745ac..37e4487c2fb 100644 --- a/include/syslog.h +++ b/include/syslog.h @@ -29,6 +29,9 @@ #include #include +#ifdef CONFIG_SYSLOG_TO_SCHED_NOTE +#include +#endif #include #include @@ -205,9 +208,16 @@ extern "C" * ****************************************************************************/ +#ifndef CONFIG_SYSLOG_TO_SCHED_NOTE void syslog(int priority, FAR const IPTR char *fmt, ...) syslog_like(2, 3); void vsyslog(int priority, FAR const IPTR char *fmt, va_list ap) syslog_like(2, 0); +#else +# define syslog(priority, fmt, ...) \ + sched_note_printf(NOTE_TAG_LOG + priority, fmt, ##__VA_ARGS__) +# define vsyslog(priority, fmt, ap) \ + sched_note_vprintf(NOTE_TAG_LOG + priority, fmt, ap) +#endif /**************************************************************************** * Name: setlogmask diff --git a/libs/libc/syslog/Make.defs b/libs/libc/syslog/Make.defs index 242cd1dd5af..ffddf479761 100644 --- a/libs/libc/syslog/Make.defs +++ b/libs/libc/syslog/Make.defs @@ -22,7 +22,9 @@ # Add the internal C files to the build +ifeq ($(CONFIG_SYSLOG),y) CSRCS += lib_syslog.c lib_setlogmask.c +endif # Add the syslog directory to the build