From 0b41cf85e0dd4aba87febe9c9d8d519b306384e5 Mon Sep 17 00:00:00 2001 From: Suchang Woo Date: Fri, 7 Aug 2015 20:13:09 +0900 Subject: [PATCH] common: enable assert() and leave more detail error log Change-Id: I3c2b7ffd056e42b3adc4937aface46af51056ccd Signed-off-by: Suchang Woo --- CMakeLists.txt | 7 ++++++- client/c_log.h | 2 +- common/log.h | 6 +++--- daemon/daemon.c | 5 ++++- packaging/buxton2.spec | 5 +++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 888d33f..834385e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,11 +16,16 @@ IF(NOT DEFINED INCLUDE_INSTALL_DIR) MESSAGE(WARNING "INCLUDE_INSTALL_DIR is not defined, default value is used") ENDIF() -OPTION(NDEBUG "Debugging and assertions disabled" TRUE) +OPTION(NDEBUG "Assertions disabled" TRUE) IF(NDEBUG) ADD_DEFINITIONS(-DNDEBUG) ENDIF() +OPTION(DEBUG_LOG "Debug log enabled" FALSE) +IF(DEBUG_LOG) + ADD_DEFINITIONS(-DDEBUG_LOG) +ENDIF() + IF(NOT "${CONFPATH}" STREQUAL "") ADD_DEFINITIONS(-DCONFPATH="${CONFPATH}") ENDIF() diff --git a/client/c_log.h b/client/c_log.h index c33443e..455164b 100644 --- a/client/c_log.h +++ b/client/c_log.h @@ -18,7 +18,7 @@ #pragma once -#if defined(NDEBUG) +#if !defined(DEBUG_LOG) # define bxt_err(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__) # define bxt_dbg(fmt, ...) do { } while (0) diff --git a/common/log.h b/common/log.h index 0de5696..62d5fae 100644 --- a/common/log.h +++ b/common/log.h @@ -28,14 +28,14 @@ # include -# if defined(NDEBUG) +# if !defined(DEBUG_LOG) # define bxt_info(fmt, ...) printf("Buxton: " fmt "\n", ##__VA_ARGS__) # define bxt_err(fmt, ...) \ fprintf(stderr, "Buxton: " fmt "\n", ##__VA_ARGS__) # define bxt_dbg(fmt, ...) do { } while (0) -# else /* NDEBUG */ +# else /* DEBUG_LOG */ # define bxt_info(fmt, ...) printf("Buxton: " fmt "\n", ##__VA_ARGS__) # define bxt_err(fmt, ...) \ @@ -44,6 +44,6 @@ printf("Buxton:D:%s:%d: " fmt "\n", __func__, __LINE__, \ ##__VA_ARGS__) -# endif +# endif /* DEBUG_LOG */ #endif /* _DLOG_H_ */ diff --git a/daemon/daemon.c b/daemon/daemon.c index 1c13537..8efe794 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -703,7 +703,10 @@ static gboolean client_cb(gint fd, GIOCondition cond, gpointer data) if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) { if (cond & (G_IO_ERR | G_IO_NVAL)) - bxt_err("Client %d: IO error", fd); + bxt_err("Client %d: PID %d(%s) IO %s", fd, + cli->cred.pid, + cli->label ? cli->label : "", + cond & G_IO_ERR ? "error" : "nval"); cli->fd_id = 0; g_idle_add(del_client, cli); diff --git a/packaging/buxton2.spec b/packaging/buxton2.spec index 8bda01a..950d130 100644 --- a/packaging/buxton2.spec +++ b/packaging/buxton2.spec @@ -1,5 +1,5 @@ Name: buxton2 -Version: 1.0 +Version: 1.1 Release: 0 License: Apache-2.0 Summary: A security-enabled configuration system @@ -96,7 +96,8 @@ cp %{SOURCE1001} . -DDB_DIR:PATH=%{_localstatedir}/lib/%{name} \ -DTMPFS_DIR:PATH=/run/%{name} \ -DSOCKPATH:PATH=/run/%{name}-0 \ - -DNDEBUG:BOOL=TRUE \ + -DNDEBUG:BOOL=FALSE \ + -DDEBUG_LOG:BOOL=FALSE \ . %__make %{?_smp_mflags} -- 2.7.4