mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
syslog: support syslog redirection to sched_note
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
@@ -1383,7 +1383,6 @@ config DEBUG_SECUREFAULT
|
|||||||
|
|
||||||
config ARM_SEMIHOSTING_SYSLOG
|
config ARM_SEMIHOSTING_SYSLOG
|
||||||
bool "Semihosting SYSLOG support"
|
bool "Semihosting SYSLOG support"
|
||||||
select ARCH_SYSLOG
|
|
||||||
select SYSLOG_REGISTER
|
select SYSLOG_REGISTER
|
||||||
---help---
|
---help---
|
||||||
Enable hooks to support semihosting syslog output.
|
Enable hooks to support semihosting syslog output.
|
||||||
|
|||||||
@@ -128,7 +128,6 @@ config ARMV7M_STACKCHECK_BREAKPOINT
|
|||||||
config ARMV7M_ITMSYSLOG
|
config ARMV7M_ITMSYSLOG
|
||||||
bool "ITM SYSLOG support"
|
bool "ITM SYSLOG support"
|
||||||
default n
|
default n
|
||||||
select ARCH_SYSLOG
|
|
||||||
---help---
|
---help---
|
||||||
Enable hooks to support ITM syslog output. This requires additional
|
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
|
MCU support in order to be used. See arch/arm/src/armv7-m/itm_syslog.h
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ config ARMV8M_STACKCHECK_BREAKPOINT
|
|||||||
config ARMV8M_ITMSYSLOG
|
config ARMV8M_ITMSYSLOG
|
||||||
bool "ITM SYSLOG support"
|
bool "ITM SYSLOG support"
|
||||||
default n
|
default n
|
||||||
select ARCH_SYSLOG
|
|
||||||
---help---
|
---help---
|
||||||
Enable hooks to support ITM syslog output. This requires additional
|
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
|
MCU support in order to be used. See arch/arm/src/armv8-m/itm_syslog.h
|
||||||
|
|||||||
+35
-15
@@ -5,16 +5,48 @@
|
|||||||
|
|
||||||
menu "System Logging"
|
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
|
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
|
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
|
config SYSLOG_DEFAULT_MASK
|
||||||
hex "syslog mask default value"
|
hex "syslog mask default value"
|
||||||
default 0xff
|
default 0xff
|
||||||
|
|
||||||
|
if SYSLOG
|
||||||
comment "SYSLOG options"
|
comment "SYSLOG options"
|
||||||
|
|
||||||
config SYSLOG_MAX_CHANNELS
|
config SYSLOG_MAX_CHANNELS
|
||||||
@@ -361,19 +393,6 @@ config CONSOLE_SYSLOG
|
|||||||
example, if the only console is a Telnet console. Then in that case,
|
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.
|
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
|
config SYSLOG_IOCTL
|
||||||
bool "SYSLOG IOCTL support"
|
bool "SYSLOG IOCTL support"
|
||||||
default n
|
default n
|
||||||
@@ -388,4 +407,5 @@ config SYSLOG_REGISTER
|
|||||||
---help---
|
---help---
|
||||||
This option will support register the syslog channel dynamically.
|
This option will support register the syslog channel dynamically.
|
||||||
|
|
||||||
|
endif # SYSLOG
|
||||||
endmenu # System logging
|
endmenu # System logging
|
||||||
|
|||||||
@@ -21,14 +21,16 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# Include SYSLOG Infrastructure
|
# Include SYSLOG Infrastructure
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SYSLOG),y)
|
||||||
CSRCS += vsyslog.c syslog_channel.c syslog_putc.c
|
CSRCS += vsyslog.c syslog_channel.c syslog_putc.c
|
||||||
CSRCS += syslog_write.c syslog_flush.c
|
CSRCS += syslog_write.c syslog_flush.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSLOG_INTBUFFER),y)
|
ifeq ($(CONFIG_SYSLOG_INTBUFFER),y)
|
||||||
CSRCS += syslog_intbuffer.c
|
CSRCS += syslog_intbuffer.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_ARCH_SYSLOG),y)
|
ifeq ($(CONFIG_SYSLOG),y)
|
||||||
CSRCS += syslog_initialize.c
|
CSRCS += syslog_initialize.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -48,7 +50,9 @@ endif
|
|||||||
# System logging to a character device (or file)
|
# System logging to a character device (or file)
|
||||||
|
|
||||||
ifneq ($(CONFIG_SYSLOG_CONSOLE)$(CONFIG_SYSLOG_CHAR)$(CONFIG_SYSLOG_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
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSLOG_CHAR),y)
|
ifeq ($(CONFIG_SYSLOG_CHAR),y)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ extern "C"
|
|||||||
* g_default_channel.
|
* g_default_channel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG
|
||||||
EXTERN FAR syslog_channel_t *
|
EXTERN FAR syslog_channel_t *
|
||||||
#ifndef CONFIG_SYSLOG_REGISTER
|
#ifndef CONFIG_SYSLOG_REGISTER
|
||||||
const
|
const
|
||||||
@@ -227,6 +228,7 @@ int syslog_add_intbuffer(int ch);
|
|||||||
#ifdef CONFIG_SYSLOG_INTBUFFER
|
#ifdef CONFIG_SYSLOG_INTBUFFER
|
||||||
int syslog_flush_intbuffer(bool force);
|
int syslog_flush_intbuffer(bool force);
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* CONFIG_SYSLOG */
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -281,6 +281,15 @@ enum note_type_e
|
|||||||
enum note_tag_e
|
enum note_tag_e
|
||||||
{
|
{
|
||||||
NOTE_TAG_ALWAYS = 0,
|
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_APP,
|
||||||
NOTE_TAG_ARCH,
|
NOTE_TAG_ARCH,
|
||||||
NOTE_TAG_AUDIO,
|
NOTE_TAG_AUDIO,
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ int syslog_channel_unregister(FAR syslog_channel_t *channel);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_ARCH_SYSLOG
|
#ifdef CONFIG_SYSLOG
|
||||||
int syslog_initialize(void);
|
int syslog_initialize(void);
|
||||||
#else
|
#else
|
||||||
# define syslog_initialize()
|
# 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);
|
int syslog_flush(void);
|
||||||
|
#else
|
||||||
|
# define syslog_flush()
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nx_vsyslog
|
* 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);
|
int nx_vsyslog(int priority, FAR const IPTR char *src, FAR va_list *ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -183,7 +183,9 @@ SYSCALL_LOOKUP(clock_settime, 2)
|
|||||||
|
|
||||||
/* System logging */
|
/* System logging */
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG
|
||||||
SYSCALL_LOOKUP(nx_vsyslog, 3)
|
SYSCALL_LOOKUP(nx_vsyslog, 3)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following are defined if either file or socket descriptor are
|
/* The following are defined if either file or socket descriptor are
|
||||||
* enabled.
|
* enabled.
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
|
#ifdef CONFIG_SYSLOG_TO_SCHED_NOTE
|
||||||
|
#include <nuttx/sched_note.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.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 syslog(int priority, FAR const IPTR char *fmt, ...) syslog_like(2, 3);
|
||||||
void vsyslog(int priority, FAR const IPTR char *fmt, va_list ap)
|
void vsyslog(int priority, FAR const IPTR char *fmt, va_list ap)
|
||||||
syslog_like(2, 0);
|
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
|
* Name: setlogmask
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
# Add the internal C files to the build
|
# Add the internal C files to the build
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SYSLOG),y)
|
||||||
CSRCS += lib_syslog.c lib_setlogmask.c
|
CSRCS += lib_syslog.c lib_setlogmask.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Add the syslog directory to the build
|
# Add the syslog directory to the build
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user