From 7151fb67130ebbdc531424a4b87461e781da001f Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 15 Jun 2019 12:58:38 -0400 Subject: [PATCH] Logging: define `BT_LOG*_SUPPORTED` when logging is supported Rely on those new `BT_LOG_SUPPORTED`, `BT_LIB_LOG_SUPPORTED`, `BT_COMP_LOG_SUPPORTED`, definitions instead of the header include guards to know whether or not logging is supported at a given point. Signed-off-by: Philippe Proulx Change-Id: I4d076e30b528882d036f7cfc367b5dbb39401dda Reviewed-on: https://review.lttng.org/c/babeltrace/+/1472 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- src/ctf-writer/assert-pre.h | 2 +- src/lib/assert-pre.h | 2 +- src/lib/lib-logging.h | 2 ++ src/lib/plugin/plugin.h | 2 +- src/lib/trace-ir/event.h | 2 +- src/logging/log.h | 2 ++ src/plugins/comp-logging.h | 2 ++ 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ctf-writer/assert-pre.h b/src/ctf-writer/assert-pre.h index 0291190d..5444760d 100644 --- a/src/ctf-writer/assert-pre.h +++ b/src/ctf-writer/assert-pre.h @@ -35,7 +35,7 @@ * you also need to use logging explicitly. */ -#ifndef BABELTRACE_LOGGING_INTERNAL_H +#ifndef BT_LOG_SUPPORTED # error Include "logging/log.h" before this header. #endif diff --git a/src/lib/assert-pre.h b/src/lib/assert-pre.h index 7636b56a..9eeff141 100644 --- a/src/lib/assert-pre.h +++ b/src/lib/assert-pre.h @@ -35,7 +35,7 @@ * need to use logging explicitly. */ -#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H +#ifndef BT_LIB_LOG_SUPPORTED # error Include "lib/lib-logging.h" before this header. #endif diff --git a/src/lib/lib-logging.h b/src/lib/lib-logging.h index 9ec1fd9b..7bb36c99 100644 --- a/src/lib/lib-logging.h +++ b/src/lib/lib-logging.h @@ -190,4 +190,6 @@ int bt_lib_log_level; void bt_lib_log(const char *func, const char *file, unsigned line, int lvl, const char *tag, const char *fmt, ...); +#define BT_LIB_LOG_SUPPORTED + #endif /* BABELTRACE_LIB_LOGGING_INTERNAL_H */ diff --git a/src/lib/plugin/plugin.h b/src/lib/plugin/plugin.h index 6d9b288d..edaad960 100644 --- a/src/lib/plugin/plugin.h +++ b/src/lib/plugin/plugin.h @@ -36,7 +36,7 @@ #include "plugin-so.h" /* Protection: this file uses BT_LIB_LOG*() macros directly */ -#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H +#ifndef BT_LIB_LOG_SUPPORTED # error Please include "lib/lib-logging.h" before including this file. #endif diff --git a/src/lib/trace-ir/event.h b/src/lib/trace-ir/event.h index e1d3e441..9cfbb56a 100644 --- a/src/lib/trace-ir/event.h +++ b/src/lib/trace-ir/event.h @@ -25,7 +25,7 @@ */ /* Protection: this file uses BT_LIB_LOG*() macros directly */ -#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H +#ifndef BT_LIB_LOG_SUPPORTED # error Please include "lib/lib-logging.h" before including this file. #endif diff --git a/src/logging/log.h b/src/logging/log.h index c9aa4bad..cafde891 100644 --- a/src/logging/log.h +++ b/src/logging/log.h @@ -1143,6 +1143,8 @@ end: _level_sym = bt_log_get_level_from_env(_env_var); \ } +#define BT_LOG_SUPPORTED + #ifdef __cplusplus } #endif diff --git a/src/plugins/comp-logging.h b/src/plugins/comp-logging.h index d1399f72..612f5863 100644 --- a/src/plugins/comp-logging.h +++ b/src/plugins/comp-logging.h @@ -139,4 +139,6 @@ #define BT_COMP_LOGV_MEM(_data_ptr, _data_sz, _fmt, ...) \ BT_COMP_LOG_MEM(BT_LOG_VERBOSE, (BT_COMP_LOG_SELF_COMP), (_data_ptr), (_data_sz), _fmt, ##__VA_ARGS__) +#define BT_COMP_LOG_SUPPORTED + #endif /* BABELTRACE_PLUGINS_COMP_LOGGING_H */ -- 2.34.1