This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 536ab6c1a8c2b99ed2b5327bfdf91d8db6a5533a Author: yangao1 <[email protected]> AuthorDate: Tue Sep 8 16:14:26 2026 +0800 drivers/syslog: drop the NUL from the color reset write sizeof("\e[0m") counts the string terminator, so with CONFIG_SYSLOG_COLOR_OUTPUT every syslog message ended with a 0x00 byte after its newline. Terminals ignore it, but tools that read the log byte by byte see the NUL at the start of the next line. Write the escape sequence without its terminator. Signed-off-by: yangao1 <[email protected]> --- drivers/syslog/vsyslog.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index cd609277abc..d7d95d3f74f 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -54,6 +54,9 @@ static FAR const char * const g_priority_color[] = "", /* LOG_INFO, Normal */ "\e[2m", /* LOG_DEBUG, Dim */ }; + +# define SYSLOG_COLOR_RESET "\e[0m" +# define SYSLOG_COLOR_RESET_LEN (sizeof(SYSLOG_COLOR_RESET) - 1) #endif #if defined(CONFIG_SYSLOG_PRIORITY) @@ -163,7 +166,7 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) #if defined(CONFIG_SYSLOG_COLOR_OUTPUT) /* Reset the terminal style. */ - "\e[0m" + SYSLOG_COLOR_RESET #endif #ifdef CONFIG_SYSLOG_TIMESTAMP @@ -288,7 +291,8 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) #if defined(CONFIG_SYSLOG_COLOR_OUTPUT) /* Reset the terminal style back to normal. */ - ret += lib_stream_puts(&stream.common, "\e[0m", sizeof("\e[0m")); + ret += lib_stream_puts(&stream.common, SYSLOG_COLOR_RESET, + SYSLOG_COLOR_RESET_LEN); #endif /* Flush and destroy the syslog stream buffer */
