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 <peter.hutte...@who-t.net>
---
 test/litest.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index d91a524..acba871 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: ") ||
-- 
2.9.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to