syslog: support syslog redirection to sched_note

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai
2023-11-23 22:34:16 +08:00
committed by Xiang Xiao
parent e608d5522d
commit 211a56910a
11 changed files with 73 additions and 21 deletions
-1
View File
@@ -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.
-1
View File
@@ -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
-1
View File
@@ -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
+35 -15
View File
@@ -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
+6 -2
View File
@@ -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)
+2
View File
@@ -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
+9
View File
@@ -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,
+7 -1
View File
@@ -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
+2
View File
@@ -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.
+10
View File
@@ -29,6 +29,9 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#ifdef CONFIG_SYSLOG_TO_SCHED_NOTE
#include <nuttx/sched_note.h>
#endif
#include <stdint.h>
#include <stdarg.h>
@@ -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
+2
View File
@@ -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