So we don't have to have newline handling in the callers. This effectively reverts 6ab2999be90331 "test: detect linebreaks in log messages".
https://bugs.freedesktop.org/show_bug.cgi?id=104957 Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- src/evdev.h | 21 ++++++++++----------- test/litest.c | 15 +++------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/evdev.h b/src/evdev.h index 75223852..20a7e352 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -666,19 +666,18 @@ evdev_log_msg_va(struct evdev_device *device, const char *format, va_list args) { + char buf[1024]; + /* Anything info and above is user-visible, use the device name */ - log_msg(evdev_libinput_context(device), - priority, - "%-7s - %s%s", - evdev_device_get_sysname(device), - (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->devname : "", - (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "" - ); + snprintf(buf, + sizeof(buf), + "%-7s - %s%s%s", + evdev_device_get_sysname(device), + (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->devname : "", + (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "", + format); - log_msg_va(evdev_libinput_context(device), - priority, - format, - args); + log_msg_va(evdev_libinput_context(device), priority, buf, args); } LIBINPUT_ATTRIBUTE_PRINTF(3, 4) diff --git a/test/litest.c b/test/litest.c index dcbed5c9..a31e874e 100644 --- a/test/litest.c +++ b/test/litest.c @@ -636,7 +636,6 @@ 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; @@ -662,11 +661,7 @@ litest_log_handler(struct libinput *libinput, if (!is_tty) color = ""; - - if (had_newline) - fprintf(stderr, "%slitest %s ", color, priority); - - if (strstr(format, "tap state:")) + else if (strstr(format, "tap state:")) color = ANSI_BLUE; else if (strstr(format, "thumb state:")) color = ANSI_YELLOW; @@ -681,13 +676,9 @@ litest_log_handler(struct libinput *libinput, else if (strstr(format, "edge state:")) color = ANSI_BRIGHT_GREEN; - if (is_tty) - fprintf(stderr, "%s ", color); - + fprintf(stderr, "%slitest %s ", color, priority); vfprintf(stderr, format, args); - had_newline = strlen(format) >= 1 && - format[strlen(format) - 1] == '\n'; - if (is_tty && had_newline) + if (is_tty) fprintf(stderr, ANSI_NORMAL); if (strstr(format, "client bug: ") || -- 2.14.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel