util: Add logging utilities

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
Jonas Ådahl 2013-11-23 12:55:44 +01:00
parent 97a277a9f0
commit c0af815eae
2 changed files with 33 additions and 0 deletions

View file

@ -28,8 +28,33 @@
#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)
{

View file

@ -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.