From ba933efd9e786ac457bad17d093ee69146a447ef Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Thu, 11 May 2017 07:11:35 -0600 Subject: [PATCH] When syslog message has addition characters after last new-line. With buffering those now get lost as vsyslog does not flush output after lib_sprintf. Additional trailing characters could be ANSI escape sequence to reset state that message setups. For example, macro here uses colors and resets state after actual message (including '\n'): With flushing added to vsyslog, then there is problem that next syslog line might come from other task before reset sequence, causing wrong line getting color. This could be avoided by not flushing on '\n' but only if IOB is full and/or at end of vsyslog. Would this make sense? --- drivers/syslog/syslog_stream.c | 4 ++-- drivers/syslog/vsyslog.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/syslog/syslog_stream.c b/drivers/syslog/syslog_stream.c index 04bb0726b0..ac7e144ceb 100644 --- a/drivers/syslog/syslog_stream.c +++ b/drivers/syslog/syslog_stream.c @@ -82,9 +82,9 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch) iob->io_len++; this->nput++; - /* Is the buffer full? Did we encounter a new line? */ + /* Is the buffer full? */ - if (iob->io_len >= CONFIG_IOB_BUFSIZE || ch == '\n') + if (iob->io_len >= CONFIG_IOB_BUFSIZE) { /* Yes.. then flush the buffer */ diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index cbb8588240..94e818dc04 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -130,6 +130,10 @@ int _vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) ret = lib_vsprintf(&stream.public, fmt, *ap); + /* Flush the output */ + + stream.public.flush(&stream.public); + #ifdef CONFIG_SYSLOG_BUFFER /* Destroy the syslog stream buffer */