diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2024-03-15 14:56:06 +1000 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-03-18 16:25:47 +0000 |
commit | 02d01a53c6b944ecca4a8d73bd7fcec616a0d84e (patch) | |
tree | 83cb8fe0c4c1f4c887908981ea8a775b5c7eb977 | |
parent | bb1b1304dff08cf5b1b290bea7635091ef53d455 (diff) |
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>
-rw-r--r-- | src/libinput-util.h | 6 |
1 files 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"))) |