diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2014-03-26 15:49:34 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-04-10 11:11:56 +1000 |
commit | 28908b5ea231635d37d80f19becf97aff8bc4d6d (patch) | |
tree | 5edb3a505c8b2e8c320e781e51f23f053bb76e22 /tools | |
parent | c9ab49ee0c34cba0478c45deb545810190238700 (diff) | |
download | libinput-28908b5ea231635d37d80f19becf97aff8bc4d6d.tar.gz |
tools: add --verbose to event-debug
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@who-t.net>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/event-debug.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/event-debug.c b/tools/event-debug.c index 12a2df87..c0a08a7a 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; |