[PATCH libinput 3/9] tools: add --verbose to event-debug

Peter Hutterer peter.hutterer at who-t.net
Thu Mar 27 21:38:46 PDT 2014


And redirect the log to stdout. libinput logs to stderr by default, but if
we're running with --verbose we want all msgs on the same stream.

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

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 12a2df8..c0a08a7 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -46,11 +46,13 @@ static struct udev *udev;
 uint32_t start_time;
 static const uint32_t screen_width = 100;
 static const uint32_t screen_height = 100;
+static int verbose = 0;
 
 static void
 usage(void)
 {
-	printf("Usage: %s [--udev [<seat>]|--device /dev/input/event0]\n"
+	printf("Usage: %s [--verbose] [--udev [<seat>]|--device /dev/input/event0]\n"
+	       "--verbose ....... Print debugging output.\n"
 	       "--udev <seat>.... Use udev device discovery (default).\n"
 	       "		  Specifying a seat ID is optional.\n"
 	       "--device /path/to/device .... open the given device only\n",
@@ -67,6 +69,7 @@ parse_args(int argc, char **argv)
 			{ "device", 1, 0, 'd' },
 			{ "udev", 0, 0, 'u' },
 			{ "help", 0, 0, 'h' },
+			{ "verbose", 0, 0, 'v'},
 			{ 0, 0, 0, 0}
 		};
 
@@ -91,6 +94,9 @@ parse_args(int argc, char **argv)
 				if (optarg)
 					seat = optarg;
 				break;
+			case 'v': /* --verbose */
+				verbose = 1;
+				break;
 			default:
 				usage();
 				return 1;
@@ -430,6 +436,13 @@ mainloop(struct libinput *li)
 	close(fds[1].fd);
 }
 
+static void log_handler(enum libinput_log_priority priority,
+			void *user_data,
+			const char *format, va_list args)
+{
+	vprintf(format, args);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -439,6 +452,11 @@ main(int argc, char **argv)
 	if (parse_args(argc, argv))
 		return 1;
 
+	if (verbose) {
+		libinput_log_set_handler(log_handler, NULL);
+		libinput_log_set_priority(LIBINPUT_LOG_PRIORITY_DEBUG);
+	}
+
 	if (mode == MODE_UDEV) {
 		if (open_udev(&li))
 			return 1;
-- 
1.8.5.3



More information about the wayland-devel mailing list