mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
Add a hook before the existing syslog_initialize() call; rename the old syslog_initialize() to syslog_dev_initialize().
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# Include SYSLOG Infrastructure
|
# Include SYSLOG Infrastructure
|
||||||
|
|
||||||
CSRCS += vsyslog.c vlowsyslog.c syslogstream.c
|
CSRCS += syslog_initialize.c vsyslog.c vlowsyslog.c syslogstream.c
|
||||||
|
|
||||||
# The note driver is hosted in this directory, but is not associated with
|
# The note driver is hosted in this directory, but is not associated with
|
||||||
# SYSLOGging
|
# SYSLOGging
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/syslog.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __DRIVERS_SYSLOG_SYSLOG_H
|
||||||
|
#define __DRIVERS_SYSLOG_SYSLOG_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: syslog_dev_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize to use the character device (or file) at
|
||||||
|
* CONFIG_SYSLOG_DEVPATH as the SYSLOG sink.
|
||||||
|
*
|
||||||
|
* One power up, the SYSLOG facility is non-existent or limited to very
|
||||||
|
* low-level output. This function may be called later in the
|
||||||
|
* intialization sequence after full driver support has been initialized.
|
||||||
|
* (via syslog_initialize()) It installs the configured SYSLOG drivers
|
||||||
|
* and enables full SYSLOGing capability.
|
||||||
|
*
|
||||||
|
* NOTE that this implementation excludes using a network connection as
|
||||||
|
* SYSLOG device. That would be a good extension.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||||
|
* any failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_CHAR
|
||||||
|
int syslog_dev_initialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __DRIVERS_SYSLOG_SYSLOG_H */
|
||||||
@@ -226,18 +226,31 @@ static inline void syslog_flush(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: syslog_initialize
|
* Name: syslog_dev_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize to use the character device (or file) at
|
* Initialize to use the character device (or file) at
|
||||||
* CONFIG_SYSLOG_DEVPATH as the SYSLOG sink.
|
* CONFIG_SYSLOG_DEVPATH as the SYSLOG sink.
|
||||||
*
|
*
|
||||||
|
* One power up, the SYSLOG facility is non-existent or limited to very
|
||||||
|
* low-level output. This function may be called later in the
|
||||||
|
* intialization sequence after full driver support has been initialized.
|
||||||
|
* (via syslog_initialize()) It installs the configured SYSLOG drivers
|
||||||
|
* and enables full SYSLOGing capability.
|
||||||
|
*
|
||||||
* NOTE that this implementation excludes using a network connection as
|
* NOTE that this implementation excludes using a network connection as
|
||||||
* SYSLOG device. That would be a good extension.
|
* SYSLOG device. That would be a good extension.
|
||||||
*
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||||
|
* any failure.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int syslog_initialize(void)
|
int syslog_dev_initialize(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -322,9 +335,9 @@ int syslog_putc(int ch)
|
|||||||
*
|
*
|
||||||
* (1) Before the SYSLOG device has been initialized. This could happen
|
* (1) Before the SYSLOG device has been initialized. This could happen
|
||||||
* from debug output that occurs early in the boot sequence before
|
* from debug output that occurs early in the boot sequence before
|
||||||
* syslog_initialize() is called (SYSLOG_UNINITIALIZED).
|
* syslog_dev_initialize() is called (SYSLOG_UNINITIALIZED).
|
||||||
* (2) While the device is being initialized. The case could happen if
|
* (2) While the device is being initialized. The case could happen if
|
||||||
* debug output is generated while syslog_initialize() executes
|
* debug output is generated while syslog_dev_initialize() executes
|
||||||
* (SYSLOG_INITIALIZING).
|
* (SYSLOG_INITIALIZING).
|
||||||
* (3) While we are generating SYSLOG output. The case could happen if
|
* (3) While we are generating SYSLOG output. The case could happen if
|
||||||
* debug output is generated while syslog_putc() executes
|
* debug output is generated while syslog_putc() executes
|
||||||
@@ -374,7 +387,7 @@ int syslog_putc(int ch)
|
|||||||
goto errout_with_errcode;
|
goto errout_with_errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* syslog_initialize() is called as soon as enough of the operating
|
/* syslog_dev_initialize() is called as soon as enough of the operating
|
||||||
* system is in place to support the open operation... but it is
|
* system is in place to support the open operation... but it is
|
||||||
* possible that the SYSLOG device is not yet registered at that time.
|
* possible that the SYSLOG device is not yet registered at that time.
|
||||||
* In this case, we know that the system is sufficiently initialized
|
* In this case, we know that the system is sufficiently initialized
|
||||||
@@ -390,12 +403,12 @@ int syslog_putc(int ch)
|
|||||||
{
|
{
|
||||||
/* Try again to initialize the device. We may do this repeatedly
|
/* Try again to initialize the device. We may do this repeatedly
|
||||||
* because the log device might be something that was not ready
|
* because the log device might be something that was not ready
|
||||||
* the first time that syslog_initializee() was called (such as a
|
* the first time that syslog_dev_initializee() was called (such as a
|
||||||
* USB serial device that has not yet been connected or a file in
|
* USB serial device that has not yet been connected or a file in
|
||||||
* an NFS mounted file system that has not yet been mounted).
|
* an NFS mounted file system that has not yet been mounted).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = syslog_initialize();
|
ret = syslog_dev_initialize();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/syslog_initialize.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
|
||||||
|
#include "syslog.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: syslog_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* One power up, the SYSLOG facility is non-existent or limited to very
|
||||||
|
* low-level output. This function is called later in the intialization
|
||||||
|
* sequence after full driver support has been initialized. It installs
|
||||||
|
* the configured SYSLOG drivers and enables full SYSLOGing capability.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||||
|
* any failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int syslog_initialize(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Not much to this yet... more is coming */
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG) && defined(CONFIG_SYSLOG_CHAR)
|
||||||
|
/* Enable use of a character device as the SYSLOG device */
|
||||||
|
|
||||||
|
ret = syslog_dev_initialize();
|
||||||
|
#else
|
||||||
|
/* Nothing needs to be done */
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
* CONFIG_SYSLOG_CHAR - Enable the generic character device for the SYSLOG.
|
* CONFIG_SYSLOG_CHAR - Enable the generic character device for the SYSLOG.
|
||||||
* The full path to the SYSLOG device is provided by CONFIG_SYSLOG_DEVPATH.
|
* The full path to the SYSLOG device is provided by CONFIG_SYSLOG_DEVPATH.
|
||||||
* A valid character device must exist at this path. It will by opened
|
* A valid character device must exist at this path. It will by opened
|
||||||
* by syslog_initialize.
|
* by logic in syslog_initialize() based on the current configuration.
|
||||||
*
|
*
|
||||||
* NOTE: No more than one SYSLOG device should be configured.
|
* NOTE: No more than one SYSLOG device should be configured.
|
||||||
*/
|
*/
|
||||||
@@ -101,17 +101,21 @@ extern "C"
|
|||||||
* Name: syslog_initialize
|
* Name: syslog_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize to use the character device (or file) at
|
* One power up, the SYSLOG facility is non-existent or limited to very
|
||||||
* CONFIG_SYSLOG_DEVPATH as the SYSLOG sink.
|
* low-level output. This function is called later in the intialization
|
||||||
|
* sequence after full driver support has been initialized. It installs
|
||||||
|
* the configured SYSLOG drivers and enables full SYSLOGing capability.
|
||||||
*
|
*
|
||||||
* NOTE that this implementation excludes using a network connection as
|
* Input Parameters:
|
||||||
* SYSLOG device. That would be a good extension.
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||||
|
* any failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SYSLOG_CHAR
|
|
||||||
int syslog_initialize(void);
|
int syslog_initialize(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: syslog_putc
|
* Name: syslog_putc
|
||||||
|
|||||||
Reference in New Issue
Block a user