From 3b737887f3c99558356bd101922e80b1361740e1 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 2 Dec 2013 00:10:41 +0100 Subject: [PATCH] Add --debug option to configure. --- configure.ac | 6 ++++++ src/socket2unix.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 61ecbbb..d61de2e 100644 --- a/configure.ac +++ b/configure.ac @@ -37,5 +37,11 @@ AC_TYPE_SIZE_T AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([dlsym() is required])]) +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug],[enable debug output])], + [if test "x$enableval" = xyes; then + AC_DEFINE([DEBUG], 1, [Define to 1 enable debug output.]) + fi]) + AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT diff --git a/src/socket2unix.c b/src/socket2unix.c index 848a40b..e912387 100644 --- a/src/socket2unix.c +++ b/src/socket2unix.c @@ -22,6 +22,8 @@ /* Necessary for RTLD_NEXT. */ #define _GNU_SOURCE +#include + #include #include #include @@ -197,7 +199,11 @@ static const char *get_socket_path(void) { static int get_log_level(void) { const char *level = getenv("SOCKET2UNIX_DEBUG"); if (!level) { +#ifdef DEBUG + return LOG_LEVEL_DEBUG; +#else return LOG_LEVEL_WARNING; +#endif } int number = atoi(level); if (number <= 0 || number > LOG_LEVEL_DEBUG) { -- 2.45.2