SYSLOG: Add option to buffer SYSLOG output to avoid interleaving.

This commit is contained in:
Gregory Nutt
2017-05-10 14:42:43 -06:00
parent 4f18b40429
commit 20727d17c3
18 changed files with 590 additions and 134 deletions
+13 -1
View File
@@ -189,6 +189,18 @@ struct lib_rawsostream_s
int fd;
};
/* This is a special stream that does buffered character I/O. NOTE that is
* CONFIG_SYSLOG_BUFFER is not defined, it is the same as struct lib_outstream_s */
struct lib_syslogstream_s
{
struct lib_outstream_s public;
#ifdef CONFIG_SYSLOG_BUFFER
unsigned int nbuf;
char buf[CONFIG_SYSLOG_BUFSIZE];
#endif
};
/****************************************************************************
* Public Data
****************************************************************************/
@@ -360,7 +372,7 @@ void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
*
****************************************************************************/
void syslogstream(FAR struct lib_outstream_s *stream);
void syslogstream(FAR struct lib_syslogstream_s *stream);
/****************************************************************************
* Name: emergstream
+8 -2
View File
@@ -43,6 +43,8 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
#include <stdarg.h>
/****************************************************************************
@@ -104,6 +106,7 @@ enum syslog_init_e
/* This structure provides the interface to a SYSLOG device */
typedef CODE ssize_t (*syslog_write_t)(FAR const char *buf, size_t buflen);
typedef CODE int (*syslog_putc_t)(int ch);
typedef CODE int (*syslog_flush_t)(void);
@@ -111,8 +114,11 @@ struct syslog_channel_s
{
/* I/O redirection methods */
syslog_putc_t sc_putc; /* Normal buffered output */
syslog_putc_t sc_force; /* Low-level output for interrupt handlers */
#ifdef CONFIG_SYSLOG_WRITE
syslog_write_t sc_write; /* Write multiple bytes */
#endif
syslog_putc_t sc_putc; /* Normal buffered output */
syslog_putc_t sc_force; /* Low-level output for interrupt handlers */
syslog_flush_t sc_flush; /* Flush buffered output (on crash) */
/* Implementation specific logic may follow */