Python plugin provider: log if Python interpreter is already initialized
[babeltrace.git] / python-plugin-provider / python-plugin-provider.c
index c276aadff3bd31989e19bc0873faba6624a051a4..2cb5a7334f82169b608d557180875e9f619dd3ec 100644 (file)
  * SOFTWARE.
  */
 
-#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
 #define BT_LOG_TAG "PLUGIN-PY"
-#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 "logging.h"
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler-internal.h>
@@ -65,13 +58,6 @@ 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)
 {
@@ -113,9 +99,13 @@ void init_python(void)
        }
 
        if (!Py_IsInitialized()) {
+               BT_LOGI_STR("Python interpreter is not initialized: initializing Python interpreter.");
                Py_InitializeEx(0);
                BT_LOGI("Initialized Python interpreter: version=\"%s\"",
                        Py_GetVersion());
+       } else {
+               BT_LOGI("Python interpreter is already initialized: version=\"%s\"",
+                       Py_GetVersion());
        }
 
        py_bt2_py_plugin_mod = PyImport_ImportModule("bt2.py_plugin");
This page took 0.033856 seconds and 4 git commands to generate.