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>
This commit is contained in:
Peter Hutterer 2014-03-26 15:49:34 +10:00
parent c9ab49ee0c
commit 28908b5ea2

View file

@ -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;