From d4b76be18b9bcbdb497de1040855d80972c3bbb2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 6 Feb 2018 11:51:29 +1000 Subject: [PATCH] evdev: log all evdev_msg_* on one line 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 Reviewed-by: Pekka Paalanen --- src/evdev.h | 23 +++++++++++------------ test/litest.c | 15 +++------------ 2 files changed, 14 insertions(+), 24 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) { - /* 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) ? ": " : "" - ); + char buf[1024]; - log_msg_va(evdev_libinput_context(device), - priority, - format, - args); + /* Anything info and above is user-visible, use the device name */ + 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, 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: ") ||