Logging: check `BT_DEBUG_MODE` instead of `NDEBUG`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 14 Jun 2019 21:11:40 +0000 (17:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
This project does not rely on `NDEBUG`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I35b282711f373998ea8361b343e9abf32fb6390c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1442
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/lib/logging.c
src/lib/plugin/plugin-so.c
src/logging/log.h

index 3c0178c227138916d29a6d0648c4fe642d8cc885..30ab704abd774b52a4b965c684e4c62c9f592870 100644 (file)
 # 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 */
index b7acd815ae6dfb1286e97f8a93378e696e1b0b5f..11cea29da3c1f4e298c771acbc8dfa5748156d05 100644 (file)
@@ -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);
index 42ae118b58c0a64bd354bcb43937eb263ad86c2b..ce24318f61b98424e665b4ccb280d33fb5fc21a9 100644 (file)
  *   #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
 
  *   #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
  *   #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
 {
This page took 0.027437 seconds and 4 git commands to generate.