From 6ab2999be9033189f9a5f5d14b66557688020f42 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 28 Mar 2017 11:38:12 +1000 Subject: [PATCH] test: detect linebreaks in log messages If a single log message is composed of multiple calls (as are all from evdev_log_*), don't prefix multiple times. Signed-off-by: Peter Hutterer --- test/litest.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/litest.c b/test/litest.c index d91a5242..acba8715 100644 --- a/test/litest.c +++ b/test/litest.c @@ -786,6 +786,7 @@ litest_log_handler(struct libinput *libinput, va_list args) { static int is_tty = -1; + static bool had_newline = true; const char *priority = NULL; const char *color; @@ -812,11 +813,12 @@ litest_log_handler(struct libinput *libinput, if (!is_tty) color = ""; - fprintf(stderr, "%slitest %s ", color, priority); - + if (had_newline) + fprintf(stderr, "%slitest %s ", color, priority); vfprintf(stderr, format, args); - - if (is_tty) + had_newline = strlen(format) >= 1 && + format[strlen(format) - 1] == '\n'; + if (is_tty && had_newline) fprintf(stderr, ANSI_NORMAL); if (strstr(format, "client bug: ") ||