summaryrefslogtreecommitdiff
path: root/tools/shared.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-10-06 16:03:19 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-10-07 07:22:52 +1000
commit82bf473d998abc74ea833bf354e53b9b51c73604 (patch)
tree5afce2092cbcad81810dc48c2f24777148a4e055 /tools/shared.c
parent4f282688acdab2cd388866e4afdd9c76237f43e7 (diff)
downloadlibinput-82bf473d998abc74ea833bf354e53b9b51c73604.tar.gz
tools: color-group the debugging messages
Alternate between two randomly-chosen colors for each batch of debug messages to make it easier to visually group the two. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/shared.c')
-rw-r--r--tools/shared.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/shared.c b/tools/shared.c
index fce32d71..c967e11e 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -61,15 +61,24 @@ log_handler(struct libinput *li,
{
static int is_tty = -1;
static uint32_t last_dispatch_no = 0;
+ static bool color_toggle = false;
if (is_tty == -1)
is_tty = isatty(STDOUT_FILENO);
if (is_tty) {
- if (priority >= LIBINPUT_LOG_PRIORITY_ERROR)
+ if (priority >= LIBINPUT_LOG_PRIORITY_ERROR) {
printf(ANSI_RED);
- else if (priority >= LIBINPUT_LOG_PRIORITY_INFO)
+ } else if (priority >= LIBINPUT_LOG_PRIORITY_INFO) {
printf(ANSI_HIGHLIGHT);
+ } else if (priority == LIBINPUT_LOG_PRIORITY_DEBUG) {
+ if (dispatch_counter != last_dispatch_no)
+ color_toggle = !color_toggle;
+ uint8_t r = 0,
+ g = 135,
+ b = 95 + (color_toggle ? 80 :0);
+ printf("\x1B[38;2;%u;%u;%um", r, g, b);
+ }
}
if (priority < LIBINPUT_LOG_PRIORITY_INFO) {
@@ -82,7 +91,7 @@ log_handler(struct libinput *li,
}
vprintf(format, args);
- if (is_tty && priority >= LIBINPUT_LOG_PRIORITY_INFO)
+ if (is_tty)
printf(ANSI_NORMAL);
}