From: Philippe Proulx Date: Fri, 14 Jun 2019 21:11:40 +0000 (-0400) Subject: Logging: check `BT_DEBUG_MODE` instead of `NDEBUG` X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=3f3b176151b4163f9ae85bc583865850a18a6ce4 Logging: check `BT_DEBUG_MODE` instead of `NDEBUG` This project does not rely on `NDEBUG`. Signed-off-by: Philippe Proulx Change-Id: I35b282711f373998ea8361b343e9abf32fb6390c Reviewed-on: https://review.lttng.org/c/babeltrace/+/1442 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- diff --git a/src/lib/logging.c b/src/lib/logging.c index 3c0178c2..30ab704a 100644 --- a/src/lib/logging.c +++ b/src/lib/logging.c @@ -35,11 +35,11 @@ # define DEFAULT_LOG_LEVEL BT_LOG_FATAL #else /* - * In non-developer mode, use NONE by default: we don't to print logging + * In non-developer mode, use NONE by default: we don't print logging * statements for any executable which links with the library. The - * executable should call bt_logging_set_global_level() or the - * executable's user should set the BABELTRACE_LOGGING_GLOBAL_LEVEL - * environment variable. + * executable must call bt_logging_set_global_level() or the + * executable's user must set the BABELTRACE_LOGGING_GLOBAL_LEVEL + * environment variable to enable logging. */ # define DEFAULT_LOG_LEVEL BT_LOG_NONE #endif /* BT_DEV_MODE */ diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index b7acd815..11cea29d 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -138,7 +138,7 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj) } if (shared_lib_handle->module) { -#ifndef NDEBUG +#ifndef BT_DEBUG_MODE /* * Valgrind shows incomplete stack traces when * dynamically loaded libraries are closed before it @@ -157,7 +157,7 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj) } shared_lib_handle->module = NULL; -#ifndef NDEBUG +#ifndef BT_DEBUG_MODE } else { BT_LOGI("Not closing GModule because `BABELTRACE_NO_DLCLOSE=1`: " "path=\"%s\"", path); diff --git a/src/logging/log.h b/src/logging/log.h index 42ae118b..ce24318f 100644 --- a/src/logging/log.h +++ b/src/logging/log.h @@ -81,19 +81,19 @@ * #define BT_LOG_LEVEL BT_LOG_VERBOSE * #include "logging.h" * - * If both BT_LOG_DEF_LEVEL and BT_LOG_LEVEL are undefined, then BT_LOG_INFO - * will be used for release builds (NDEBUG is defined) and BT_LOG_DEBUG - * otherwise (NDEBUG is not defined). + * If both BT_LOG_DEF_LEVEL and BT_LOG_LEVEL are undefined, then + * BT_LOG_INFO will be used for release builds (BT_DEBUG_MODE is NOT + * defined) and BT_LOG_DEBUG otherwise (BT_DEBUG_MODE is defined). */ #if defined(BT_LOG_LEVEL) #define _BT_LOG_LEVEL BT_LOG_LEVEL #elif defined(BT_LOG_DEF_LEVEL) #define _BT_LOG_LEVEL BT_LOG_DEF_LEVEL #else - #ifdef NDEBUG - #define _BT_LOG_LEVEL BT_LOG_INFO - #else + #ifdef BT_DEBUG_MODE #define _BT_LOG_LEVEL BT_LOG_DEBUG + #else + #define _BT_LOG_LEVEL BT_LOG_INFO #endif #endif @@ -243,18 +243,19 @@ * #include "logging.h" * * If both BT_LOG_DEF_SRCLOC and BT_LOG_SRCLOC are undefined, then - * BT_LOG_SRCLOC_NONE will be used for release builds (NDEBUG is defined) and - * BT_LOG_SRCLOC_LONG otherwise (NDEBUG is not defined). + * BT_LOG_SRCLOC_NONE will be used for release builds (BT_DEBUG_MODE is + * NOT defined) and BT_LOG_SRCLOC_LONG otherwise (BT_DEBUG_MODE is + * defined). */ #if defined(BT_LOG_SRCLOC) #define _BT_LOG_SRCLOC BT_LOG_SRCLOC #elif defined(BT_LOG_DEF_SRCLOC) #define _BT_LOG_SRCLOC BT_LOG_DEF_SRCLOC #else - #ifdef NDEBUG - #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE - #else + #ifdef BT_DEBUG_MODE #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_LONG + #else + #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE #endif #endif #if BT_LOG_SRCLOC_LONG == _BT_LOG_SRCLOC @@ -291,18 +292,18 @@ * #include "logging.h" * * If both BT_LOG_DEF_CENSORING and BT_LOG_CENSORING are undefined, then - * BT_LOG_CENSORED will be used for release builds (NDEBUG is defined) and - * BT_LOG_UNCENSORED otherwise (NDEBUG is not defined). + * BT_LOG_CENSORED will be used for release builds (BT_DEBUG_MODE is NOT + * defined) and BT_LOG_UNCENSORED otherwise (BT_DEBUG_MODE is defined). */ #if defined(BT_LOG_CENSORING) #define _BT_LOG_CENSORING BT_LOG_CENSORING #elif defined(BT_LOG_DEF_CENSORING) #define _BT_LOG_CENSORING BT_LOG_DEF_CENSORING #else - #ifdef NDEBUG - #define _BT_LOG_CENSORING BT_LOG_CENSORED - #else + #ifdef BT_DEBUG_MODE #define _BT_LOG_CENSORING BT_LOG_UNCENSORED + #else + #define _BT_LOG_CENSORING BT_LOG_CENSORED #endif #endif @@ -513,8 +514,8 @@ void bt_log_set_output_level(const int lvl); * log message. Default value is BT_LOG_PUT_STD and other flags could be used to * alter its behavior. See bt_log_set_output_v() for more details. * - * Note about BT_LOG_PUT_SRC: it will be added only in debug builds (NDEBUG is - * not defined). + * Note about BT_LOG_PUT_SRC: it will be added only in debug builds + * (BT_DEBUG_MODE is defined). */ enum {