AC_DEFINE([HAVE_TBM], [1], [Build the tbm backend])
PEPPER_REQUIRES="$PEPPER_REQUIRES libtbm wayland-tbm-server"
fi
-
AM_CONDITIONAL([HAVE_TBM], [test "x${have_tbm}" = "xyes"])
+PKG_CHECK_MODULES(DLOG, dlog, [have_dlog="yes"], [have_dlog="no"])
+if test "x${have_dlog}" = "xyes"; then
+ AC_DEFINE([HAVE_DLOG], [1], [Define to 1 if you have dlog])
+ PEPPER_REQUIRES="$PEPPER_REQUIRES dlog"
+fi
+AM_CONDITIONAL([HAVE_DLOG], [test "x${have_dlog}" = "xyes"])
+
PEPPER_DIR="-I\$(top_srcdir)/src/lib/pepper"
PEPPER_LIB="\$(top_srcdir)/src/lib/pepper/libpepper.la"
%if "%{ENABLE_TDM}" == "1"
BuildRequires: pkgconfig(libtdm)
%endif
+BuildRequires: pkgconfig(dlog)
%description
Pepper is a lightweight and flexible library for developing various types of wayland compositors.
libpepper_la_CFLAGS = $(AM_CFLAGS) $(PEPPER_CFLAGS)
libpepper_la_LIBADD = $(PEPPER_LIBS) -lm
+if HAVE_DLOG
+libpepper_la_CFLAGS += $(DLOG_CFLAGS)
+libpepper_la_LIBADD += $(DLOG_LIBS)
+endif
+
libpepper_la_SOURCES = pepper.h \
pepper-internal.h \
object.c \
PEPPER_API int
pepper_create_anonymous_file(off_t size);
+typedef enum pepper_log_level {
+ PEPPER_LOG_LEVEL_NONE,
+ PEPPER_LOG_LEVEL_DEBUG,
+ PEPPER_LOG_LEVEL_ERROR
+} pepper_log_level_t;
+
PEPPER_API int
pepper_log(const char *domain, int level, const char *format, ...);
+PEPPER_API void
+pepper_log_dlog_enable(pepper_bool_t enabled);
+
#define PEPPER_ERROR(fmt, ...) \
do { \
- pepper_log("ERROR", 0, "%s:%s: " fmt, __FILE__, __FUNCTION__, ##__VA_ARGS__); \
+ pepper_log("ERROR", PEPPER_LOG_LEVEL_ERROR, "%s:%s: " fmt, \
+ __FILE__, __FUNCTION__, ##__VA_ARGS__); \
} while (0)
#define PEPPER_TRACE(fmt, ...) \
do { \
- pepper_log("DEBUG", 0, fmt, ##__VA_ARGS__); \
+ pepper_log("DEBUG", PEPPER_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__); \
} while (0)
#define PEPPER_CHECK(exp, action, fmt, ...) \
#include <stdarg.h>
#include <time.h>
#include <sys/time.h>
+#include <config.h>
+
+#ifdef HAVE_DLOG
+# include <dlog.h>
+# ifdef LOG_TAG
+# undef LOG_TAG
+# endif
+# define LOG_TAG "PEPPER"
+#endif
static FILE *pepper_log_file;
static int pepper_log_verbosity = 3;
+#ifdef HAVE_DLOG
+static pepper_bool_t pepper_dlog_enable = PEPPER_FALSE;
+#endif
static int cached_tm_mday = -1;
static void __attribute__ ((constructor))
}
static int
-pepper_vlog(const char *format, va_list ap)
+pepper_vlog(const char *format, int level, va_list ap)
{
+#ifdef HAVE_DLOG
+ int dlog_level = DLOG_INFO;
+
+ if (pepper_dlog_enable)
+ {
+ if (level == PEPPER_LOG_LEVEL_DEBUG)
+ dlog_level = DLOG_DEBUG;
+ else if (level == PEPPER_LOG_LEVEL_ERROR)
+ dlog_level = DLOG_ERROR;
+
+ return dlog_vprint(dlog_level, LOG_TAG, format, ap);
+ }
+#endif
return vfprintf(pepper_log_file, format, ap);
}
PEPPER_API int
pepper_log(const char *domain, int level, const char *format, ...)
{
- int l;
+ int l = 0;
va_list argp;
if (level > pepper_log_verbosity || level < 0)
return 0;
-
+#ifdef HAVE_DLOG
+ if (!pepper_dlog_enable)
+ {
+ l = pepper_print_timestamp();
+ l += pepper_print_domain(domain);
+ }
+#else
l = pepper_print_timestamp();
l += pepper_print_domain(domain);
+#endif
va_start(argp, format);
- l += pepper_vlog(format, argp);
+ l += pepper_vlog(format, level, argp);
va_end(argp);
return l;
}
+
+PEPPER_API void
+pepper_log_dlog_enable(pepper_bool_t enabled)
+{
+#ifdef HAVE_DLOG
+ pepper_dlog_enable = enabled;
+#else
+ ;
+#endif
+}