Fix: make Python plugin provider have its own log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 29 May 2017 18:28:30 +0000 (14:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 20:58:12 +0000 (16:58 -0400)
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 <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/logging-internal.h
python-plugin-provider/python-plugin-provider.c

index bbe3596b905fbd9724ff91533afe68a42e87d8a5..e9ce365e19281f8b478960f760b9ccbe68b505b1 100644 (file)
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <babeltrace/logging.h>
+#include <babeltrace/babeltrace-internal.h>
 
 /* 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
index a07e187f7ddb95c2226f11110c35822df3e02f7b..c276aadff3bd31989e19bc0873faba6624a051a4 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
 #define BT_LOG_TAG "PLUGIN-PY"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/logging-internal.h>
+
+/*
+ * 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 <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler-internal.h>
@@ -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)
 {
This page took 0.026733 seconds and 4 git commands to generate.