syslog: fix extra line breaks in syslog when SYSLOG_COLOR_OUTPUT is enabled

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2022-12-30 17:09:45 +08:00 committed by Xiang Xiao
parent a4ca15aa3e
commit 275b2e70a4
3 changed files with 11 additions and 7 deletions

View File

@ -222,6 +222,11 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
ret += lib_vsprintf(&stream.public, fmt, *ap);
if (stream.last_ch != '\n')
{
lib_stream_putc(&stream.public, '\n');
}
#if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
/* Reset the terminal style back to normal. */

View File

@ -456,7 +456,11 @@ void lib_syslogstream_open(FAR struct lib_syslogstream_s *stream);
*
****************************************************************************/
#ifdef CONFIG_SYSLOG_BUFFER
void lib_syslogstream_close(FAR struct lib_syslogstream_s *stream);
#else
# define lib_syslogstream_close(s)
#endif
/****************************************************************************
* Name: lib_lzfoutstream

View File

@ -214,16 +214,11 @@ 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)
@ -237,5 +232,5 @@ void lib_syslogstream_close(FAR struct lib_syslogstream_s *stream)
iob_free(stream->iob);
stream->iob = NULL;
}
#endif
}
#endif