util: Add logging utilities
authorJonas Ådahl <jadahl@gmail.com>
Sat, 23 Nov 2013 11:55:44 +0000 (12:55 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Sat, 23 Nov 2013 11:55:44 +0000 (12:55 +0100)
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
src/libinput-util.c
src/libinput-util.h

index 9d9d4dd..a3534e1 100644 (file)
 
 #include "config.h"
 
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libinput-util.h"
 #include "libinput-private.h"
 
+static FILE *g_log_file = NULL;
+
+void
+set_logging_enabled(int enabled)
+{
+       g_log_file = enabled ? stdout : NULL;
+}
+
+void
+log_info(const char *format, ...)
+{
+       va_list ap;
+
+       if (g_log_file) {
+               va_start(ap, format);
+               vfprintf(g_log_file, format, ap);
+               va_end(ap);
+       }
+}
+
 void
 list_init(struct list *list)
 {
index 1395106..a9efb49 100644 (file)
 #ifndef LIBINPUT_UTIL_H
 #define LIBINPUT_UTIL_H
 
+#include "libinput.h"
+
+void
+set_logging_enabled(int enabled);
+
+void
+log_info(const char *format, ...);
+
 /*
  * This list data structure is a verbatim copy from wayland-util.h from the
  * Wayland project; except that wl_ prefix has been removed.