summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-03-28 11:31:16 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-03-28 18:56:38 +1000
commit0bd36f25422a0a40d1eeededabfe9f434e164c06 (patch)
treee50a16b5412efcd32a9ba90d4ec7d530a35407d3 /test
parent937541cb82bb7e9fb22c30cab3d402482e8909ac (diff)
test: add color to litest verbose output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test')
-rw-r--r--test/litest.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/test/litest.c b/test/litest.c
index f9797b7..d91a524 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -785,19 +785,40 @@ litest_log_handler(struct libinput *libinput,
const char *format,
va_list args)
{
+ static int is_tty = -1;
const char *priority = NULL;
+ const char *color;
+
+ if (is_tty == -1)
+ is_tty = isatty(STDERR_FILENO);
switch(pri) {
- case LIBINPUT_LOG_PRIORITY_INFO: priority = "info "; break;
- case LIBINPUT_LOG_PRIORITY_ERROR: priority = "error"; break;
- case LIBINPUT_LOG_PRIORITY_DEBUG: priority = "debug"; break;
+ case LIBINPUT_LOG_PRIORITY_INFO:
+ priority = "info ";
+ color = ANSI_HIGHLIGHT;
+ break;
+ case LIBINPUT_LOG_PRIORITY_ERROR:
+ priority = "error";
+ color = ANSI_RED;
+ break;
+ case LIBINPUT_LOG_PRIORITY_DEBUG:
+ priority = "debug";
+ color = ANSI_NORMAL;
+ break;
default:
abort();
}
- fprintf(stderr, "litest %s ", priority);
+ if (!is_tty)
+ color = "";
+
+ fprintf(stderr, "%slitest %s ", color, priority);
+
vfprintf(stderr, format, args);
+ if (is_tty)
+ fprintf(stderr, ANSI_NORMAL);
+
if (strstr(format, "client bug: ") ||
strstr(format, "libinput bug: "))
litest_abort_msg("libinput bug triggered, aborting.\n");