mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
syslog: A trailing newline is added if none is present.
refs: https://www.manpagez.com/man/3/syslog/ Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -111,16 +111,17 @@ static void syslogstream_addchar(FAR struct lib_syslogstream_s *stream,
|
||||
|
||||
static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
{
|
||||
FAR struct lib_syslogstream_s *stream =
|
||||
(FAR struct lib_syslogstream_s *)this;
|
||||
|
||||
DEBUGASSERT(stream != NULL);
|
||||
stream->last_ch = ch;
|
||||
|
||||
/* Discard carriage returns */
|
||||
|
||||
if (ch != '\r')
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_BUFFER
|
||||
FAR struct lib_syslogstream_s *stream =
|
||||
(FAR struct lib_syslogstream_s *)this;
|
||||
|
||||
DEBUGASSERT(stream != NULL);
|
||||
|
||||
/* Do we have an IO buffer? */
|
||||
|
||||
if (stream->iob != NULL)
|
||||
@@ -213,11 +214,16 @@ void lib_syslogstream_open(FAR struct lib_syslogstream_s *stream)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSLOG_BUFFER
|
||||
void lib_syslogstream_close(FAR struct lib_syslogstream_s *stream)
|
||||
{
|
||||
DEBUGASSERT(stream != NULL);
|
||||
|
||||
if (stream->last_ch != '\n')
|
||||
{
|
||||
syslogstream_putc(&stream->public, '\n');
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SYSLOG_BUFFER
|
||||
/* Verify that there is an IOB attached (there should be) */
|
||||
|
||||
if (stream->iob != NULL)
|
||||
@@ -231,5 +237,5 @@ void lib_syslogstream_close(FAR struct lib_syslogstream_s *stream)
|
||||
iob_free(stream->iob);
|
||||
stream->iob = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user