From 02d01a53c6b944ecca4a8d73bd7fcec616a0d84e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 15 Mar 2024 14:56:06 +1000 Subject: [PATCH] util: slightly improve the trace() macro Only one printf call instead of three, means better termination of the color code. And auto-append the newline while we're there and use the ANSI defines we have since added. Part-of: --- src/libinput-util.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libinput-util.h b/src/libinput-util.h index 8b14f76d..1f9863c6 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -58,9 +58,9 @@ #define trace(...) \ do { \ - printf("%s() - \033[0;31m", __func__); \ - printf(__VA_ARGS__); \ - printf("\033[0m"); \ + char buf_[1024]; \ + snprintf(buf_, sizeof(buf_), __VA_ARGS__); \ + printf(ANSI_BLUE "%s():%d - " ANSI_RED "%s" ANSI_NORMAL "\n", __func__, __LINE__, buf_); \ } while (0) #define LIBINPUT_EXPORT __attribute__ ((visibility("default")))