[PATCH libinput] tools: print errors as highlighted

Peter Hutterer peter.hutterer at who-t.net
Tue Feb 14 01:56:47 UTC 2017


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/shared.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/shared.c b/tools/shared.c
index 1019184..b976633 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -72,7 +72,20 @@ log_handler(struct libinput *li,
 	    const char *format,
 	    va_list args)
 {
+#define ANSI_HIGHLIGHT "\x1B[0;1;39m"
+#define ANSI_NORMAL "\x1B[0m"
+	static int is_tty = -1;
+
+	if (is_tty == -1)
+		is_tty = isatty(STDOUT_FILENO);
+
+	if (is_tty && priority > LIBINPUT_LOG_PRIORITY_INFO)
+		printf(ANSI_HIGHLIGHT);
+
 	vprintf(format, args);
+
+	if (is_tty && priority > LIBINPUT_LOG_PRIORITY_INFO)
+		printf(ANSI_NORMAL);
 }
 
 void
-- 
2.9.3



More information about the wayland-devel mailing list