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: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
This commit is contained in:
Peter Hutterer 2024-03-15 14:56:06 +10:00 committed by Marge Bot
parent bb1b1304df
commit 02d01a53c6

View file

@ -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")))