diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-03-28 11:38:12 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-03-28 18:56:38 +1000 |
commit | 6ab2999be9033189f9a5f5d14b66557688020f42 (patch) | |
tree | 4a5a4d21f61ad5a6ae30acc3f2df8884f09aac41 /test | |
parent | 0bd36f25422a0a40d1eeededabfe9f434e164c06 (diff) |
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 <peter.hutterer@who-t.net>
Diffstat (limited to 'test')
-rw-r--r-- | test/litest.c | 10 |
1 files 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: ") || |