syslog/channel: move syslog channel map into rodata

add SYSLOG_REGISTER to support disable syslog channel register

Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
chao an 2024-09-26 10:16:21 +08:00 committed by Xiang Xiao
parent 9abe737ef3
commit a04e44ea75
4 changed files with 21 additions and 3 deletions

View file

@ -1374,6 +1374,7 @@ 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.

View file

@ -196,6 +196,7 @@ if !ARCH_SYSLOG
config SYSLOG_CHAR
bool "Log to a character device"
default n
select SYSLOG_REGISTER
---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
@ -231,6 +232,7 @@ config SYSLOG_CONSOLE
bool "Log to /dev/console"
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
depends on DEV_CONSOLE
select SYSLOG_REGISTER
---help---
Use the system console as a SYSLOG output device.
@ -291,6 +293,7 @@ config SYSLOG_RPMSG_SERVER_CHARDEV
menuconfig SYSLOG_FILE
bool "Syslog file output"
default n
select SYSLOG_REGISTER
---help---
Build in support to use a file to collect SYSLOG output. File SYSLOG
channels differ from other SYSLOG channels in that they cannot be
@ -375,4 +378,9 @@ config SYSLOG_IOCTL
commands are SYSLOGIOC_SETFILTER/SYSLOGIOC_GETCHANNELS, which can be
used to set the enable status of different channels
config SYSLOG_REGISTER
bool "Register syslog channel support"
---help---
This option will support register the syslog channel dynamically.
endmenu # System logging

View file

@ -47,7 +47,11 @@ extern "C"
* g_default_channel.
*/
EXTERN FAR syslog_channel_t *g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];
EXTERN FAR syslog_channel_t *
#ifndef CONFIG_SYSLOG_REGISTER
const
#endif
g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];
/****************************************************************************
* Public Function Prototypes

View file

@ -191,8 +191,11 @@ static syslog_channel_t g_default_channel =
/* This is the current syslog channel in use */
FAR syslog_channel_t
*g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
FAR syslog_channel_t *
#ifndef CONFIG_SYSLOG_REGISTER
const
#endif
g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
{
#if defined(CONFIG_SYSLOG_DEFAULT)
&g_default_channel,
@ -272,6 +275,7 @@ static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
*
****************************************************************************/
#ifdef CONFIG_SYSLOG_REGISTER
int syslog_channel_register(FAR syslog_channel_t *channel)
{
#if (CONFIG_SYSLOG_MAX_CHANNELS != 1)
@ -369,3 +373,4 @@ int syslog_channel_unregister(FAR syslog_channel_t *channel)
return -EINVAL;
}
#endif