Add per-device log handlers
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 14 May 2014 06:36:49 +0000 (16:36 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 5 Jun 2014 05:16:06 +0000 (15:16 +1000)
commit93bc9a329d622fe28aae101710163fae6f03850c
tree5518cb8d8ae4051ae0e48291a54cf7ee71c1d6b4
parenta5a10423122a67662c36c47a993c1dd4417a7de1
Add per-device log handlers

The global log handler isn't a good choice for a low-level library. In the
caser of the X server, both evdev and synaptics are now using the libevdev but
are loaded from the same server process. Thus, there's only one log handler,
but evdev and synaptics don't talk to each other (a bit childish, I know).

Add a per-device log handler that overrides the global log handler, and fall
back to the global log handler if no device log handler is set. The log
macros take care of that automatically, especially as we can't do per-device
log handlers for the uinput code.

Note that we use the same struct for the global and device logging, so in each
instance one of the two function pointers is NULL. Suicide triggers are in
place in case we mess that up.

This also makes libevdev_new_from_fd() a bit less useful since we can't set
the log handler beforehand.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
libevdev/libevdev-int.h
libevdev/libevdev-uinput.c
libevdev/libevdev.c
libevdev/libevdev.h
libevdev/libevdev.sym
test/test-libevdev-init.c