From c0af815eaec66fa340dbb491606efc23e9f661b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 23 Nov 2013 12:55:44 +0100 Subject: [PATCH] util: Add logging utilities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Ã…dahl --- src/libinput-util.c | 25 +++++++++++++++++++++++++ src/libinput-util.h | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/src/libinput-util.c b/src/libinput-util.c index 9d9d4dd8..a3534e1c 100644 --- a/src/libinput-util.c +++ b/src/libinput-util.c @@ -28,8 +28,33 @@ #include "config.h" +#include +#include +#include + +#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) { diff --git a/src/libinput-util.h b/src/libinput-util.h index 1395106e..a9efb499 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -23,6 +23,14 @@ #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.