Add a log_msg_va function
authorHans de Goede <hdegoede@redhat.com>
Tue, 10 Jun 2014 13:08:03 +0000 (15:08 +0200)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 11 Jun 2014 00:31:43 +0000 (10:31 +1000)
This is useful for when we use libraries which want us to provide them with
a logging callback.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/libinput-private.h
src/libinput.c

index c18447a60bc1a5c3db3cc708243f2023eca6df63..f0bda1f804e2d8bfb59910386595fc69fa9cc668 100644 (file)
@@ -97,6 +97,10 @@ typedef void (*libinput_source_dispatch_t)(void *data);
 
 void
 log_msg(enum libinput_log_priority priority, const char *format, ...);
+void
+log_msg_va(enum libinput_log_priority priority,
+          const char *format,
+          va_list args);
 
 int
 libinput_init(struct libinput *libinput,
index aee373eb898e7aaf757439700d01484e6cf00d6e..5b10a10a7f53e7361c401ab3aceb86c41b8a0489 100644 (file)
@@ -110,16 +110,23 @@ static struct log_data log_data = {
        .user_data = NULL,
 };
 
+void
+log_msg_va(enum libinput_log_priority priority,
+          const char *format,
+          va_list args)
+{
+       if (log_data.handler && log_data.priority <= priority)
+               log_data.handler(priority, log_data.user_data, format, args);
+}
+
 void
 log_msg(enum libinput_log_priority priority, const char *format, ...)
 {
        va_list args;
 
-       if (log_data.handler && log_data.priority <= priority) {
-               va_start(args, format);
-               log_data.handler(priority, log_data.user_data, format, args);
-               va_end(args);
-       }
+       va_start(args, format);
+       log_msg_va(priority, format, args);
+       va_end(args);
 }
 
 LIBINPUT_EXPORT void