From 7f8b9578155e3a870d7e6e7520313a45392151c6 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 29 May 2017 14:28:30 -0400 Subject: [PATCH] Fix: make Python plugin provider have its own log level MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It cannot share libbabeltrace's log level because it's in a different shared object itself. Because it's not using the library's global log level, we don't initialize it with the BABELTRACE_LOGGING_GLOBAL_LEVEL, but with its own BABELTRACE_PYTHON_PROVIDER_LOG_LEVEL. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- include/babeltrace/logging-internal.h | 1 + python-plugin-provider/python-plugin-provider.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/babeltrace/logging-internal.h b/include/babeltrace/logging-internal.h index bbe3596b..e9ce365e 100644 --- a/include/babeltrace/logging-internal.h +++ b/include/babeltrace/logging-internal.h @@ -12,6 +12,7 @@ #include #include #include +#include /* To detect incompatible changes you can define BT_LOG_VERSION_REQUIRED to be * the current value of BT_LOG_VERSION before including this file (or via diff --git a/python-plugin-provider/python-plugin-provider.c b/python-plugin-provider/python-plugin-provider.c index a07e187f..c276aadf 100644 --- a/python-plugin-provider/python-plugin-provider.c +++ b/python-plugin-provider/python-plugin-provider.c @@ -24,8 +24,15 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level #define BT_LOG_TAG "PLUGIN-PY" -#include +#include + +/* + * Must be before the rest because some of the headers below could + * contain logging statements which need this symbol when expanded. + */ +static int python_plugin_provider_log_level = BT_LOG_NONE; #include #include @@ -58,6 +65,13 @@ enum python_state { static PyObject *py_try_load_plugin_module_func = NULL; +static +void __attribute__((constructor)) logging_ctor(void) +{ + python_plugin_provider_log_level = + bt_log_get_level_from_env("BABELTRACE_PYTHON_PLUGIN_PROVIDER_LOG_LEVEL"); +} + static void print_python_traceback_warn(void) { -- 2.34.1