Move the OS intensive part of vsyslog and vlowsyslog to drivers/syslog/vsyslog.c and vlowsyslog.c. Also move lib_syslogstrem to drivers/syslog/syslogstream.c
This commit is contained in:
parent
f5e5908a70
commit
34f776dce9
@ -2,7 +2,7 @@
|
|||||||
# drivers/syslog/Make.defs
|
# drivers/syslog/Make.defs
|
||||||
# These drivers support system logging devices
|
# These drivers support system logging devices
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -35,60 +35,38 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Include SYSLOG drivers (only one should be enabled)
|
# Include SYSLOG Infrastructure
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSLOG),y)
|
CSRCS += vsyslog.c vlowsyslog.c syslogstream.c
|
||||||
|
|
||||||
# If no special loggin devices are implemented, then the default SYSLOG
|
# The note driver is hosted in this directory, but is not associated with
|
||||||
# logic at fs/fs_syslog.c will be used
|
# SYSLOGging
|
||||||
|
|
||||||
# (Add other SYSLOG drivers here)
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_RAMLOG),y)
|
|
||||||
CSRCS += ramlog.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_DRIVER_NOTE),y)
|
ifeq ($(CONFIG_DRIVER_NOTE),y)
|
||||||
CSRCS += note_driver.c
|
CSRCS += note_driver.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# (Add other SYSLOG_CONSOLE drivers here)
|
############################################################################
|
||||||
|
# Include SYSLOG drivers (only one should be enabled)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_RAMLOG),y)
|
||||||
|
CSRCS += ramlog.c
|
||||||
|
else ifeq ($(CONFIG_SYSLOG),y)
|
||||||
|
|
||||||
|
# If no special logging devices are implemented, then the default SYSLOG
|
||||||
|
# logic at fs/fs_syslog.c will be used
|
||||||
|
|
||||||
|
# (Add other SYSLOG drivers here)
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSLOG_CONSOLE),y)
|
ifeq ($(CONFIG_SYSLOG_CONSOLE),y)
|
||||||
CSRCS += syslog_console.c
|
CSRCS += syslog_console.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# (Add other SYSLOG_CONSOLE drivers here)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
# Include SYSLOG build support
|
# Include SYSLOG build support
|
||||||
|
|
||||||
DEPPATH += --dep-path syslog
|
DEPPATH += --dep-path syslog
|
||||||
VPATH += :syslog
|
VPATH += :syslog
|
||||||
|
|
||||||
############################################################################
|
|
||||||
# The RAMLOG can be used even if system logging is not enabled.
|
|
||||||
|
|
||||||
else ifeq ($(CONFIG_RAMLOG),y)
|
|
||||||
|
|
||||||
CSRCS += ramlog.c
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_DRIVER_NOTE),y)
|
|
||||||
CSRCS += note_driver.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Include RAMLOG build support
|
|
||||||
|
|
||||||
DEPPATH += --dep-path syslog
|
|
||||||
VPATH += :syslog
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
# The scheduler note driver can be used in any event.
|
|
||||||
|
|
||||||
else ifeq ($(CONFIG_DRIVER_NOTE),y)
|
|
||||||
|
|
||||||
CSRCS += note_driver.c
|
|
||||||
|
|
||||||
# Include note driver build support
|
|
||||||
|
|
||||||
DEPPATH += --dep-path syslog
|
|
||||||
VPATH += :syslog
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/syslog/lib_syslogstream.c
|
* drivers/syslog/syslogstream.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -47,14 +47,8 @@
|
|||||||
#include <nuttx/syslog/syslog.h>
|
#include <nuttx/syslog/syslog.h>
|
||||||
#include <nuttx/streams.h>
|
#include <nuttx/streams.h>
|
||||||
|
|
||||||
#include "syslog/syslog.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_SYSLOG
|
#ifdef CONFIG_SYSLOG
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor definition
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -97,21 +91,22 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lib_syslogstream
|
* Name: syslogstream
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initializes a stream for use with the configured syslog interface.
|
* Initializes a stream for use with the configured syslog interface.
|
||||||
|
* Only accessible from with the OS SYSLOG logic.
|
||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* lowoutstream - User allocated, uninitialized instance of struct
|
* stream - User allocated, uninitialized instance of struct
|
||||||
* lib_lowoutstream_s to be initialized.
|
* lib_lowoutstream_s to be initialized.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None (User allocated instance initialized).
|
* None (User allocated instance initialized).
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void lib_syslogstream(FAR struct lib_outstream_s *stream)
|
void syslogstream(FAR struct lib_outstream_s *stream)
|
||||||
{
|
{
|
||||||
stream->put = syslogstream_putc;
|
stream->put = syslogstream_putc;
|
||||||
#ifdef CONFIG_STDIO_LINEBUFFER
|
#ifdef CONFIG_STDIO_LINEBUFFER
|
81
drivers/syslog/vlowsyslog.c
Normal file
81
drivers/syslog/vlowsyslog.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/vlowsyslog.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2009, 2011-2012, 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 <syslog.h>
|
||||||
|
|
||||||
|
#include <nuttx/streams.h>
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
|
||||||
|
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_SYSLOG)
|
||||||
|
/* The low-level SYSLOG functions can be used only if we have access to
|
||||||
|
* either the low-level serial interface, up_putc(), and to syslog_putc()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: _vlowsyslog
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* _vlowsyslog() handles the system logging system calls. It is functionally
|
||||||
|
* equivalent to vlowsyslog() except that the pre-process priority filtering
|
||||||
|
* has already been performed and, hence, there is no priority argument.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int _vlowsyslog(FAR const IPTR char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
struct lib_outstream_s stream;
|
||||||
|
|
||||||
|
/* Wrap the stdout in a stream object and let lib_vsprintf do the work. */
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG
|
||||||
|
syslogstream((FAR struct lib_outstream_s *)&stream);
|
||||||
|
#else
|
||||||
|
lib_lowoutstream((FAR struct lib_outstream_s *)&stream);
|
||||||
|
#endif
|
||||||
|
return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_ARCH_LOWPUTC || CONFIG_SYSLOG */
|
195
drivers/syslog/vsyslog.c
Normal file
195
drivers/syslog/vsyslog.c
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/vsyslog.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2009, 2011-2014, 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 <syslog.h>
|
||||||
|
|
||||||
|
#include <nuttx/init.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/clock.h>
|
||||||
|
#include <nuttx/streams.h>
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: vsyslog_internal
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is the internal implementation of vsyslog (see the description of
|
||||||
|
* syslog and vsyslog below)
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static inline int vsyslog_internal(FAR const IPTR char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
#if defined(CONFIG_SYSLOG)
|
||||||
|
struct lib_outstream_s stream;
|
||||||
|
#elif CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
|
struct lib_rawoutstream_s stream;
|
||||||
|
#elif defined(CONFIG_ARCH_LOWPUTC)
|
||||||
|
struct lib_outstream_s stream;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
/* Get the current time. Since debug output may be generated very early
|
||||||
|
* in the start-up sequence, hardware timer support may not yet be
|
||||||
|
* available.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!OSINIT_HW_READY() || clock_systimespec(&ts) < 0)
|
||||||
|
{
|
||||||
|
/* Timer hardware is not available, or clock_systimespec failed */
|
||||||
|
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG)
|
||||||
|
/* Wrap the low-level output in a stream object and let lib_vsprintf
|
||||||
|
* do the work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syslogstream((FAR struct lib_outstream_s *)&stream);
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
||||||
|
/* Pre-pend the message with the current time, if available */
|
||||||
|
|
||||||
|
(void)lib_sprintf((FAR struct lib_outstream_s *)&stream,
|
||||||
|
"[%6d.%06d]", ts.tv_sec, ts.tv_nsec/1000);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap);
|
||||||
|
|
||||||
|
#elif CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
|
/* Wrap the stdout in a stream object and let lib_vsprintf
|
||||||
|
* do the work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
lib_rawoutstream(&stream, 1);
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
||||||
|
/* Pre-pend the message with the current time, if available */
|
||||||
|
|
||||||
|
(void)lib_sprintf((FAR struct lib_outstream_s *)&stream,
|
||||||
|
"[%6d.%06d]", ts.tv_sec, ts.tv_nsec/1000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return lib_vsprintf(&stream.public, fmt, ap);
|
||||||
|
|
||||||
|
#elif defined(CONFIG_ARCH_LOWPUTC)
|
||||||
|
/* Wrap the low-level output in a stream object and let lib_vsprintf
|
||||||
|
* do the work.
|
||||||
|
* REVISIT: lib_lowoutstream() is only available in the FLAT build or
|
||||||
|
* the kernel phase of other builds.
|
||||||
|
*/
|
||||||
|
|
||||||
|
lib_lowoutstream((FAR struct lib_outstream_s *)&stream);
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
||||||
|
/* Pre-pend the message with the current time, if available */
|
||||||
|
|
||||||
|
(void)lib_sprintf((FAR struct lib_outstream_s *)&stream,
|
||||||
|
"[%6d.%06d]", ts.tv_sec, ts.tv_nsec/1000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap);
|
||||||
|
|
||||||
|
#else /* CONFIG_SYSLOG */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#endif /* CONFIG_SYSLOG */
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: _vsyslog
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* _vsyslog() handles the system logging system calls. It is functionally
|
||||||
|
* equivalent to vsyslog() except that the pre-process priority filtering
|
||||||
|
* has already been performed and, hence, there is no priority argument.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int _vsyslog(FAR const IPTR char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
#if !defined(CONFIG_SYSLOG) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
|
/* We are generating output on stdout. So check if this function was
|
||||||
|
* called from an interrupt handler. We cannot send data to stdout from
|
||||||
|
* an interrupt handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (up_interrupt_context())
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_ARCH_LOWPUTC
|
||||||
|
/* But the low-level serial interface up_putc() is provided so we may
|
||||||
|
* be able to generate low-level serial output instead.
|
||||||
|
* NOTE: The low-level serial output is not necessarily the same
|
||||||
|
* output destination as stdout!
|
||||||
|
*/
|
||||||
|
|
||||||
|
ret = _lowvsyslog(fmt, ap);
|
||||||
|
|
||||||
|
#endif /* CONFIG_ARCH_LOWPUTC */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* !CONFIG_SYSLOG && CONFIG_NFILE_DESCRIPTORS > 0 */
|
||||||
|
{
|
||||||
|
/* Let vsylog_internal do the deed */
|
||||||
|
|
||||||
|
ret = vsyslog_internal(fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/nuttx/streams.h
|
* include/nuttx/streams.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2011-2012, 2014-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -354,14 +354,15 @@ void lib_nullinstream(FAR struct lib_instream_s *nullinstream);
|
|||||||
void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
|
void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lib_sylogstream
|
* Name: syslogstream
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initializes a stream for use with the configured syslog interface.
|
* Initializes a stream for use with the configured syslog interface.
|
||||||
|
* Only accessible from with the OS SYSLOG logic.
|
||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* lowoutstream - User allocated, uninitialized instance of struct
|
* stream - User allocated, uninitialized instance of struct
|
||||||
* lib_lowoutstream_s to be initialized.
|
* lib_lowoutstream_s to be initialized.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None (User allocated instance initialized).
|
* None (User allocated instance initialized).
|
||||||
@ -369,7 +370,7 @@ void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SYSLOG
|
#ifdef CONFIG_SYSLOG
|
||||||
void lib_syslogstream(FAR struct lib_outstream_s *stream);
|
void syslogstream(FAR struct lib_outstream_s *stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* include/nuttx/syslog/syslog.h
|
* include/nuttx/syslog/syslog.h
|
||||||
* The NuttX SYSLOGing interface
|
* The NuttX SYSLOGing interface
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012, 2014-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -128,6 +128,19 @@ int syslog_initialize(void);
|
|||||||
int syslog_putc(int ch);
|
int syslog_putc(int ch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: _vsyslog and _vlowsyslog
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* _vsyslog() handles the system logging system calls. It is functionally
|
||||||
|
* equivalent to vsyslog() except that the pre-process priority filtering
|
||||||
|
* has already been performed and, hence, there is no priority argument.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int _vsyslog(FAR const IPTR char *src, va_list ap);
|
||||||
|
int _lowvsyslog(FAR const IPTR char *src, va_list ap);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@
|
|||||||
|
|
||||||
/* Unconditional system logging */
|
/* Unconditional system logging */
|
||||||
|
|
||||||
#define SYS_vsyslog (__SYS_syslog+0)
|
#define SYS__vsyslog (__SYS_syslog+0)
|
||||||
#define __SYS_descriptors (__SYS_syslog+1)
|
#define __SYS_descriptors (__SYS_syslog+1)
|
||||||
|
|
||||||
/* The following are defined if either file or socket descriptor are
|
/* The following are defined if either file or socket descriptor are
|
||||||
|
@ -37,10 +37,6 @@
|
|||||||
|
|
||||||
CSRCS += lib_syslog.c lib_lowsyslog.c lib_setlogmask.c
|
CSRCS += lib_syslog.c lib_lowsyslog.c lib_setlogmask.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSLOG),y)
|
|
||||||
CSRCS += lib_syslogstream.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Add the syslog directory to the build
|
# Add the syslog directory to the build
|
||||||
|
|
||||||
DEPPATH += --dep-path syslog
|
DEPPATH += --dep-path syslog
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* lib/syslog/lib_lowsyslog.c
|
* lib/syslog/lib_lowsyslog.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -39,10 +39,9 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include <nuttx/streams.h>
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
|
||||||
#include "syslog/syslog.h"
|
#include "syslog/syslog.h"
|
||||||
|
|
||||||
@ -57,33 +56,6 @@
|
|||||||
* kernel two pass builds.
|
* kernel two pass builds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: lowvsyslog_internal
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This is the internal implementation of lowvsyslog (see the description
|
|
||||||
* of lowsyslog and lowvsyslog below)
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static inline int lowvsyslog_internal(FAR const IPTR char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
struct lib_outstream_s stream;
|
|
||||||
|
|
||||||
/* Wrap the stdout in a stream object and let lib_vsprintf do the work. */
|
|
||||||
|
|
||||||
#ifdef CONFIG_SYSLOG
|
|
||||||
lib_syslogstream((FAR struct lib_outstream_s *)&stream);
|
|
||||||
#else
|
|
||||||
lib_lowoutstream((FAR struct lib_outstream_s *)&stream);
|
|
||||||
#endif
|
|
||||||
return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -106,9 +78,9 @@ int lowvsyslog(int priority, FAR const IPTR char *fmt, va_list ap)
|
|||||||
|
|
||||||
if ((g_syslog_mask & LOG_MASK(priority)) != 0)
|
if ((g_syslog_mask & LOG_MASK(priority)) != 0)
|
||||||
{
|
{
|
||||||
/* Yes.. let vsylog_internal to the deed */
|
/* Perform the _lowvsyslog system call */
|
||||||
|
|
||||||
ret = lowvsyslog_internal(fmt, ap);
|
ret = _lowvsyslog(fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -39,116 +39,12 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include <nuttx/init.h>
|
#include <nuttx/syslog/syslog.h>
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/clock.h>
|
|
||||||
#include <nuttx/streams.h>
|
|
||||||
|
|
||||||
#include "syslog/syslog.h"
|
#include "syslog/syslog.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: vsyslog_internal
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This is the internal implementation of vsyslog (see the description of
|
|
||||||
* syslog and vsyslog below)
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static inline int vsyslog_internal(FAR const IPTR char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
#if defined(CONFIG_SYSLOG)
|
|
||||||
struct lib_outstream_s stream;
|
|
||||||
#elif CONFIG_NFILE_DESCRIPTORS > 0
|
|
||||||
struct lib_rawoutstream_s stream;
|
|
||||||
#elif defined(CONFIG_ARCH_LOWPUTC)
|
|
||||||
struct lib_outstream_s stream;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
/* Get the current time. Since debug output may be generated very early
|
|
||||||
* in the start-up sequence, hardware timer support may not yet be
|
|
||||||
* available.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!OSINIT_HW_READY() || clock_systimespec(&ts) < 0)
|
|
||||||
{
|
|
||||||
/* Timer hardware is not available, or clock_systimespec failed */
|
|
||||||
|
|
||||||
ts.tv_sec = 0;
|
|
||||||
ts.tv_nsec = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG)
|
|
||||||
/* Wrap the low-level output in a stream object and let lib_vsprintf
|
|
||||||
* do the work.
|
|
||||||
* REVISIT: lib_syslogstream() is only available in the FLAT build or
|
|
||||||
* the kernel phase of other builds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
lib_syslogstream((FAR struct lib_outstream_s *)&stream);
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
|
||||||
/* Pre-pend the message with the current time, if available */
|
|
||||||
|
|
||||||
(void)lib_sprintf((FAR struct lib_outstream_s *)&stream,
|
|
||||||
"[%6d.%06d]", ts.tv_sec, ts.tv_nsec/1000);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap);
|
|
||||||
|
|
||||||
#elif CONFIG_NFILE_DESCRIPTORS > 0
|
|
||||||
/* Wrap the stdout in a stream object and let lib_vsprintf
|
|
||||||
* do the work.
|
|
||||||
*/
|
|
||||||
|
|
||||||
lib_rawoutstream(&stream, 1);
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
|
||||||
/* Pre-pend the message with the current time, if available */
|
|
||||||
|
|
||||||
(void)lib_sprintf((FAR struct lib_outstream_s *)&stream,
|
|
||||||
"[%6d.%06d]", ts.tv_sec, ts.tv_nsec/1000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return lib_vsprintf(&stream.public, fmt, ap);
|
|
||||||
|
|
||||||
#elif defined(CONFIG_ARCH_LOWPUTC)
|
|
||||||
/* Wrap the low-level output in a stream object and let lib_vsprintf
|
|
||||||
* do the work.
|
|
||||||
* REVISIT: lib_lowoutstream() is only available in the FLAT build or
|
|
||||||
* the kernel phase of other builds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
lib_lowoutstream((FAR struct lib_outstream_s *)&stream);
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
|
||||||
/* Pre-pend the message with the current time, if available */
|
|
||||||
|
|
||||||
(void)lib_sprintf((FAR struct lib_outstream_s *)&stream,
|
|
||||||
"[%6d.%06d]", ts.tv_sec, ts.tv_nsec/1000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap);
|
|
||||||
|
|
||||||
#else /* CONFIG_SYSLOG */
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#endif /* CONFIG_SYSLOG */
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -167,43 +63,13 @@ int vsyslog(int priority, FAR const IPTR char *fmt, va_list ap)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
#if defined(CONFIG_BUILD_FLAT) || defined (__KERNEL__)
|
/* Check if this priority is enabled */
|
||||||
/* up_interrupt_context() and lowvsyslog() are only available in the FLAT
|
|
||||||
* build or during the kernel pass of the protected or kernel two pass
|
|
||||||
* builds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(CONFIG_SYSLOG) && CONFIG_NFILE_DESCRIPTORS > 0
|
if ((g_syslog_mask & LOG_MASK(priority)) != 0)
|
||||||
/* We are generating output on stdout. So check if this function was
|
|
||||||
* called from an interrupt handler. We cannot send data to stdout from
|
|
||||||
* an interrupt handler.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (up_interrupt_context())
|
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ARCH_LOWPUTC
|
/* Yes.. lPerform the _vsyslog system cal */
|
||||||
/* But the low-level serial interface up_putc() is provided so we may
|
|
||||||
* be able to generate low-level serial output instead.
|
|
||||||
* NOTE: The low-level serial output is not necessarily the same
|
|
||||||
* output destination as stdout!
|
|
||||||
*/
|
|
||||||
|
|
||||||
ret = lowvsyslog(priority, fmt, ap);
|
ret = _vsyslog(fmt, ap);
|
||||||
|
|
||||||
#endif /* CONFIG_ARCH_LOWPUTC */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif /* !CONFIG_SYSLOG && CONFIG_NFILE_DESCRIPTORS > 0 */
|
|
||||||
#endif /* CONFIG_BUILD_FLAT || __KERNEL */
|
|
||||||
{
|
|
||||||
/* Check if this priority is enabled */
|
|
||||||
|
|
||||||
if ((g_syslog_mask & LOG_MASK(priority)) != 0)
|
|
||||||
{
|
|
||||||
/* Yes.. let vsylog_internal do the deed */
|
|
||||||
|
|
||||||
ret = vsyslog_internal(fmt, ap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
|
@ -159,7 +159,7 @@
|
|||||||
"up_assert","assert.h","","void","FAR const uint8_t*","int"
|
"up_assert","assert.h","","void","FAR const uint8_t*","int"
|
||||||
#"up_assert","assert.h","","void"
|
#"up_assert","assert.h","","void"
|
||||||
"vfork","unistd.h","defined(CONFIG_ARCH_HAVE_VFORK)","pid_t"
|
"vfork","unistd.h","defined(CONFIG_ARCH_HAVE_VFORK)","pid_t"
|
||||||
"vsyslog","syslog.h","","int","int","FAR const IPTR char*","va_list"
|
"_vsyslog","syslog.h","","int","FAR const IPTR char*","va_list"
|
||||||
"wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","int*"
|
"wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","int*"
|
||||||
"waitid","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","int","idtype_t","id_t"," FAR siginfo_t *","int"
|
"waitid","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","int","idtype_t","id_t"," FAR siginfo_t *","int"
|
||||||
"waitpid","sys/wait.h","defined(CONFIG_SCHED_WAITPID)","pid_t","pid_t","int*","int"
|
"waitpid","sys/wait.h","defined(CONFIG_SCHED_WAITPID)","pid_t","pid_t","int*","int"
|
||||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -72,7 +72,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <mqueue.h>
|
#include <mqueue.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/* Errno access is awkward. We need to generate get_errno() and set_errno()
|
/* Errno access is awkward. We need to generate get_errno() and set_errno()
|
||||||
|
@ -165,7 +165,7 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
|
|||||||
|
|
||||||
/* System logging */
|
/* System logging */
|
||||||
|
|
||||||
SYSCALL_LOOKUP(vsyslog, 3, STUB_vsyslog)
|
SYSCALL_LOOKUP(_vsyslog, 2, STUB__vsyslog)
|
||||||
|
|
||||||
/* The following are defined if either file or socket descriptor are
|
/* The following are defined if either file or socket descriptor are
|
||||||
* enabled.
|
* enabled.
|
||||||
|
@ -167,8 +167,7 @@ uintptr_t STUB_timer_settime(int nbr, uintptr_t parm1, uintptr_t parm2,
|
|||||||
|
|
||||||
/* System logging */
|
/* System logging */
|
||||||
|
|
||||||
uintptr_t STUB_vsyslog(int nbr, uintptr_t parm1, uintptr_t parm2,
|
uintptr_t STUB__vsyslog(int nbr, uintptr_t parm1, uintptr_t parm2);
|
||||||
uintptr_t parm3);
|
|
||||||
|
|
||||||
/* The following are defined if either file or socket descriptor are
|
/* The following are defined if either file or socket descriptor are
|
||||||
* enabled.
|
* enabled.
|
||||||
|
Loading…
Reference in New Issue
Block a user