mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 04:18:01 +02:00
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:
parent
c9ab49ee0c
commit
28908b5ea2
1 changed files with 19 additions and 1 deletions
|
|
@ -46,11 +46,13 @@ static struct udev *udev;
|
||||||
uint32_t start_time;
|
uint32_t start_time;
|
||||||
static const uint32_t screen_width = 100;
|
static const uint32_t screen_width = 100;
|
||||||
static const uint32_t screen_height = 100;
|
static const uint32_t screen_height = 100;
|
||||||
|
static int verbose = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(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"
|
"--udev <seat>.... Use udev device discovery (default).\n"
|
||||||
" Specifying a seat ID is optional.\n"
|
" Specifying a seat ID is optional.\n"
|
||||||
"--device /path/to/device .... open the given device only\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' },
|
{ "device", 1, 0, 'd' },
|
||||||
{ "udev", 0, 0, 'u' },
|
{ "udev", 0, 0, 'u' },
|
||||||
{ "help", 0, 0, 'h' },
|
{ "help", 0, 0, 'h' },
|
||||||
|
{ "verbose", 0, 0, 'v'},
|
||||||
{ 0, 0, 0, 0}
|
{ 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -91,6 +94,9 @@ parse_args(int argc, char **argv)
|
||||||
if (optarg)
|
if (optarg)
|
||||||
seat = optarg;
|
seat = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'v': /* --verbose */
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -430,6 +436,13 @@ mainloop(struct libinput *li)
|
||||||
close(fds[1].fd);
|
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
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -439,6 +452,11 @@ main(int argc, char **argv)
|
||||||
if (parse_args(argc, argv))
|
if (parse_args(argc, argv))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
libinput_log_set_handler(log_handler, NULL);
|
||||||
|
libinput_log_set_priority(LIBINPUT_LOG_PRIORITY_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == MODE_UDEV) {
|
if (mode == MODE_UDEV) {
|
||||||
if (open_udev(&li))
|
if (open_udev(&li))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue