SYSLOG channel add functions return handle to the channel.
This commit is contained in:
parent
038941b11d
commit
e189d83e11
@ -392,7 +392,8 @@ mounting of the file systems.
|
||||
The interface ``syslog_file_channel()`` is used to configure the
|
||||
SYSLOG file channel:
|
||||
|
||||
.. c:function:: int syslog_file_channel(FAR const char *devpath);
|
||||
.. c:function:: FAR struct syslog_channel_s *
|
||||
syslog_file_channel(FAR const char *devpath);
|
||||
|
||||
Configure to use a file in a mounted file system
|
||||
at ``devpath`` as the SYSLOG channel.
|
||||
@ -423,8 +424,8 @@ SYSLOG file channel:
|
||||
``syslog_file_channel()`` will create the file.
|
||||
|
||||
:return:
|
||||
Zero (``OK``) is returned on success; a
|
||||
negated ``errno`` value is returned on any failure.
|
||||
A pointer to the new syslog channel; ``NULL`` is returned
|
||||
on any failure.
|
||||
|
||||
References: ``drivers/syslog/syslog_filechannel.c``,
|
||||
``drivers/syslog/syslog_device.c``, and
|
||||
|
@ -96,11 +96,12 @@ int board_app_initialize(uintptr_t arg)
|
||||
|
||||
nxsig_usleep(CONFIG_CLICKER2_STM32_SYSLOG_FILE_DELAY * 1000);
|
||||
|
||||
ret = syslog_file_channel(CONFIG_CLICKER2_STM32_SYSLOG_FILE_PATH);
|
||||
if (ret < 0)
|
||||
FAR struct syslog_channel_s *channel;
|
||||
channel = syslog_file_channel(CONFIG_CLICKER2_STM32_SYSLOG_FILE_PATH);
|
||||
if (channel == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: syslog_file_channel() failed: %d\n", ret);
|
||||
return ret;
|
||||
syslog(LOG_ERR, "ERROR: syslog_file_channel() failed\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -372,7 +372,7 @@ SYSLOG Channel Options
|
||||
Prototype:
|
||||
|
||||
#ifdef CONFIG_SYSLOG_FILE
|
||||
int syslog_file_channel(FAR const char *devpath);
|
||||
FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath);
|
||||
#endif
|
||||
|
||||
Description:
|
||||
@ -406,8 +406,7 @@ SYSLOG Channel Options
|
||||
|
||||
Returned Value:
|
||||
|
||||
Zero (OK) is returned on success; a negated errno value is returned on
|
||||
any failure.
|
||||
A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
|
||||
References: drivers/syslog/syslog_filechannel.c,
|
||||
drivers/syslog/syslog_device.c, and include/nuttx/syslog/syslog.h.
|
||||
|
@ -125,13 +125,12 @@ void syslog_dev_uninitialize(FAR struct syslog_channel_s *channel);
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
* A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSLOG_CHAR
|
||||
int syslog_dev_channel(void);
|
||||
FAR struct syslog_channel_s *syslog_dev_channel(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -156,13 +155,12 @@ int syslog_dev_channel(void);
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
* A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSLOG_CONSOLE
|
||||
int syslog_console_channel(void);
|
||||
FAR struct syslog_channel_s *syslog_console_channel(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -75,12 +75,11 @@ FAR static struct syslog_channel_s *g_syslog_console_channel;
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
* A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int syslog_console_channel(void)
|
||||
FAR struct syslog_channel_s *syslog_console_channel(void)
|
||||
{
|
||||
/* Initialize the character driver interface */
|
||||
|
||||
@ -88,12 +87,18 @@ int syslog_console_channel(void)
|
||||
OPEN_FLAGS, OPEN_MODE);
|
||||
if (g_syslog_console_channel == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Use the character driver as the SYSLOG channel */
|
||||
|
||||
return syslog_channel(g_syslog_console_channel);
|
||||
if (syslog_channel(g_syslog_console_channel) != OK)
|
||||
{
|
||||
syslog_dev_uninitialize(g_syslog_console_channel);
|
||||
g_syslog_console_channel = NULL;
|
||||
}
|
||||
|
||||
return g_syslog_console_channel;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SYSLOG_CONSOLE */
|
||||
|
@ -72,12 +72,11 @@ FAR static struct syslog_channel_s *g_syslog_dev_channel;
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
* A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int syslog_dev_channel(void)
|
||||
FAR struct syslog_channel_s *syslog_dev_channel(void)
|
||||
{
|
||||
/* Initialize the character driver interface */
|
||||
|
||||
@ -85,12 +84,18 @@ int syslog_dev_channel(void)
|
||||
OPEN_FLAGS, OPEN_MODE);
|
||||
if (g_syslog_dev_channel == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Use the character driver as the SYSLOG channel */
|
||||
|
||||
return syslog_channel(g_syslog_dev_channel);
|
||||
if (syslog_channel(g_syslog_dev_channel) != OK)
|
||||
{
|
||||
syslog_dev_uninitialize(g_syslog_dev_channel);
|
||||
g_syslog_dev_channel = NULL;
|
||||
}
|
||||
|
||||
return g_syslog_dev_channel;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SYSLOG_CHAR */
|
||||
|
@ -85,15 +85,12 @@ FAR static struct syslog_channel_s *g_syslog_file_channel;
|
||||
* file.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
* A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int syslog_file_channel(FAR const char *devpath)
|
||||
FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Reset the default SYSLOG channel so that we can safely modify the
|
||||
* SYSLOG device. This is an atomic operation and we should be safe
|
||||
* after the default channel has been selected.
|
||||
@ -117,7 +114,6 @@ int syslog_file_channel(FAR const char *devpath)
|
||||
OPEN_MODE);
|
||||
if (g_syslog_file_channel == NULL)
|
||||
{
|
||||
ret = -ENOMEM;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
@ -125,11 +121,15 @@ int syslog_file_channel(FAR const char *devpath)
|
||||
* screwed.
|
||||
*/
|
||||
|
||||
ret = syslog_channel(g_syslog_file_channel);
|
||||
if (syslog_channel(g_syslog_file_channel) != OK)
|
||||
{
|
||||
syslog_dev_uninitialize(g_syslog_file_channel);
|
||||
g_syslog_file_channel = NULL;
|
||||
}
|
||||
|
||||
errout_with_lock:
|
||||
sched_unlock();
|
||||
return ret;
|
||||
return g_syslog_file_channel;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SYSLOG_FILE */
|
||||
|
@ -72,11 +72,11 @@ int syslog_initialize(void)
|
||||
#if defined(CONFIG_SYSLOG_CHAR)
|
||||
/* Enable use of a character device as the SYSLOG device */
|
||||
|
||||
ret = syslog_dev_channel();
|
||||
syslog_dev_channel();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
/* Use the console device as the SYSLOG device */
|
||||
|
||||
ret = syslog_console_channel();
|
||||
syslog_console_channel();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RAMLOG_SYSLOG
|
||||
|
@ -233,13 +233,12 @@ int syslog_initialize(void);
|
||||
* file.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
* A pointer to the new SYSLOG channel; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSLOG_FILE
|
||||
int syslog_file_channel(FAR const char *devpath);
|
||||
FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user