mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 05:13:35 +08:00
Add logic to re-direct debug output to a sysloggin device
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4381 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
* include/nuttx/lib.h
|
||||
* Non-standard, internal APIs available in lib/.
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2007-2009, 2012 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
|
||||
@@ -34,8 +34,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __LIB_H
|
||||
#define __LIB_H
|
||||
#ifndef __INCLUDE_NUTTX_LIB_H
|
||||
#define __INCLUDE_NUTTX_LIB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@@ -80,4 +80,4 @@ EXTERN void lib_releaselist(FAR struct streamlist *list);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __LIB_H */
|
||||
#endif /* __INCLUDE_NUTTX_LIB_H */
|
||||
|
||||
@@ -63,18 +63,33 @@
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_RAMLOG - Enables the RAM logging feature
|
||||
* CONFIG_RAMLOG_CONSOLE - Use the RAM logging device as a system console.
|
||||
* If this feature is enabled (along with CONFIG_DEV_CONSOLE), then all
|
||||
* console output will be re-directed to a circular buffer in RAM. This
|
||||
* is useful, for example, if the only console is a Telnet console. Then
|
||||
* in that case, console output from non-Telnet threads will go to the
|
||||
* circular buffer and can be viewed using the NSH 'dmesg' command.
|
||||
* CONFIG_RAMLOG_SYSLOG - Use the RAM logging device for the syslogging
|
||||
* interface. This should have:
|
||||
* CONFIG_SYSLOG=ramlog
|
||||
* interface. If this feature is enabled (along with CONFIG_SYSLOG),
|
||||
* then all debug output (only) will be re-directed to the circular
|
||||
* buffer in RAM. This RAM log can be view from NSH using the 'dmesg'
|
||||
* command.
|
||||
* CONFIG_RAMLOG_NPOLLWAITERS - The number of threads than can be waiting
|
||||
* for this driver on poll(). Default: 4
|
||||
*
|
||||
* If CONFIG_RAMLOG_CONSOLE is selected, then the following may also be
|
||||
* provided:
|
||||
* If CONFIG_RAMLOG_CONSOLE or CONFIG_RAMLOG_SYSLOG is selected, then the
|
||||
* following may also be provided:
|
||||
*
|
||||
* CONFIG_RAMLOG_CONSOLE_BUFSIZE - Size of the console RAM log. Default: 1024
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DEV_CONSOLE
|
||||
# undef CONFIG_RAMLOG_CONSOLE
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SYSLOG
|
||||
# undef CONFIG_RAMLOG_SYSLOG
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_RAMLOG_NPOLLWAITERS
|
||||
# define CONFIG_RAMLOG_NPOLLWAITERS 4
|
||||
#endif
|
||||
@@ -104,19 +119,31 @@ extern "C" {
|
||||
*
|
||||
* Description:
|
||||
* Create the RAM logging device and register it at the specified path.
|
||||
* Mostly likely this path will be /dev/console
|
||||
* Mostly likely this path will be /dev/console.
|
||||
*
|
||||
* This interface is not normally used but can be made available is
|
||||
* someone just wants to tinker with the RAM log as a generic character
|
||||
* device. Normally both CONFIG_RAMLOG_CONSOLE and CONFIG_RAMLOG_SYSLOG
|
||||
* would be set (to capture all output in the log) -OR- just
|
||||
* CONFIG_RAMLOG_SYSLOG would be set to capture debug output only
|
||||
* in the log.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_RAMLOG_CONSOLE) && !defined(CONFIG_RAMLOG_SYSLOG)
|
||||
EXTERN int ramlog_register(FAR const char *devpath, FAR char *buffer,
|
||||
size_t buflen);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ramlog_consoleinit
|
||||
*
|
||||
* Description:
|
||||
* Create the RAM logging device and register it at the specified path.
|
||||
* Mostly likely this path will be /dev/console
|
||||
* Mostly likely this path will be /dev/console.
|
||||
*
|
||||
* If CONFIG_RAMLOG_SYSLOG is also defined, then the same RAM logging
|
||||
* device is also registered at /dev/syslog
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -124,6 +151,22 @@ EXTERN int ramlog_register(FAR const char *devpath, FAR char *buffer,
|
||||
EXTERN int ramlog_consoleinit(void)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ramlog_sysloginit
|
||||
*
|
||||
* Description:
|
||||
* Create the RAM logging device and register it at the specified path.
|
||||
* Mostly likely this path will be /dev/syslog
|
||||
*
|
||||
* If CONFIG_RAMLOG_CONSOLE is also defined, then this functionality is
|
||||
* performed when ramlog_consoleinit() is called.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_RAMLOG_CONSOLE) && defined(CONFIG_RAMLOG_SYSLOG)
|
||||
EXTERN int ramlog_sysloginit(void)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ramlog
|
||||
*
|
||||
@@ -137,8 +180,8 @@ EXTERN int ramlog_consoleinit(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_RAMLOG_SYSLOG
|
||||
# warning "Missing logic"
|
||||
#if defined(CONFIG_RAMLOG_CONSOLE) || defined(CONFIG_RAMLOG_SYSLOG)
|
||||
EXTERN int ramlog_putc(int ch);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/streams.h
|
||||
*
|
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2009, 2011-2012 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
|
||||
@@ -268,6 +268,25 @@ EXTERN void lib_zeroinstream(FAR struct lib_instream_s *zeroinstream);
|
||||
EXTERN void lib_nullinstream(FAR struct lib_instream_s *nullinstream);
|
||||
EXTERN void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lib_sylogstream
|
||||
*
|
||||
* Description:
|
||||
* Initializes a stream for use with the configured syslog interface.
|
||||
*
|
||||
* Input parameters:
|
||||
* lowoutstream - User allocated, uninitialized instance of struct
|
||||
* lib_lowoutstream_s to be initialized.
|
||||
*
|
||||
* Returned Value:
|
||||
* None (User allocated instance initialized).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSLOG
|
||||
EXTERN void lib_sylogstream(FAR struct lib_outstream_s *stream);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user