Fix -Wmissing-prototypes/-Wmissing-declarations warnings
[babeltrace.git] / src / python-plugin-provider / python-plugin-provider.c
index 5bdcbfcd78c035ec4bbbd0a4249d8b7c077d1efb..d1bc73a166e05a2cadd60fcbe61950e1c6b93ece 100644 (file)
  */
 
 #define BT_LOG_TAG "LIB/PLUGIN-PY"
-
 #include "lib/logging.h"
+
+#include "python-plugin-provider.h"
+
 #include "common/macros.h"
 #include "compat/compiler.h"
 #include <babeltrace2/plugin/plugin-const.h>
@@ -72,7 +74,7 @@ void append_python_traceback_error_cause(void)
        GString *exc = NULL;
 
        if (Py_IsInitialized() && PyErr_Occurred()) {
-               exc = bt_py_common_format_exception(BT_LOG_OUTPUT_LEVEL);
+               exc = bt_py_common_format_current_exception(BT_LOG_OUTPUT_LEVEL);
                if (!exc) {
                        BT_LOGE_STR("Failed to format Python exception.");
                        goto end;
@@ -94,7 +96,7 @@ void log_python_traceback(int log_level)
        GString *exc = NULL;
 
        if (Py_IsInitialized() && PyErr_Occurred()) {
-               exc = bt_py_common_format_exception(BT_LOG_OUTPUT_LEVEL);
+               exc = bt_py_common_format_current_exception(BT_LOG_OUTPUT_LEVEL);
                if (!exc) {
                        BT_LOGE_STR("Failed to format Python exception.");
                        goto end;
@@ -145,12 +147,14 @@ int init_python(void)
 
        /*
         * User can disable Python plugin support with the
-        * BABELTRACE_DISABLE_PYTHON_PLUGINS environment variable set to
-        * 1.
+        * `LIBBABELTRACE2_DISABLE_PYTHON_PLUGINS` environment variable
+        * set to 1.
         */
-       dis_python_env = getenv("BABELTRACE_DISABLE_PYTHON_PLUGINS");
+       dis_python_env = getenv("LIBBABELTRACE2_DISABLE_PYTHON_PLUGINS");
        if (dis_python_env && strcmp(dis_python_env, "1") == 0) {
-               BT_LOGI_STR("Python plugin support is disabled because `BABELTRACE_DISABLE_PYTHON_PLUGINS=1`.");
+               BT_LOGI_STR("Python plugin support is disabled because the "
+                       "`LIBBABELTRACE2_DISABLE_PYTHON_PLUGINS` environment "
+                       "variable is set to `1`.");
                python_state = PYTHON_STATE_WONT_INITIALIZE;
                ret = BT_FUNC_STATUS_NOT_FOUND;
                goto end;
@@ -250,9 +254,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot find `name` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot find `name` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -268,9 +272,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot find `author` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot find `author` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -286,9 +290,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot find `description` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot find `description` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -304,9 +308,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot find `license` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot find `license` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -322,9 +326,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot find `version` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot find `version` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -341,9 +345,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot find `comp_class_addrs` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot find `comp_class_addrs` attribute in Python plugin info object: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -360,9 +364,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                BT_LIB_LOGW_APPEND_CAUSE(
                                        "Cannot decode Python plugin name string: "
                                        "py-plugin-info-addr=%p", plugin_info);
-                               status = BT_FUNC_STATUS_LOADING_ERROR;
+                               status = BT_FUNC_STATUS_ERROR;
                        } else {
-                               BT_LIB_LOGI(
+                               BT_LIB_LOGW(
                                        "Cannot decode Python plugin name string: "
                                        "py-plugin-info-addr=%p", plugin_info);
                                status = BT_FUNC_STATUS_NOT_FOUND;
@@ -377,9 +381,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Plugin name is not a string: "
                                "py-plugin-info-addr=%p", plugin_info);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Plugin name is not a string: "
                                "py-plugin-info-addr=%p", plugin_info);
                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -396,9 +400,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                BT_LIB_LOGW_APPEND_CAUSE(
                                        "Cannot decode Python plugin author string: "
                                        "py-plugin-info-addr=%p", plugin_info);
-                               status = BT_FUNC_STATUS_LOADING_ERROR;
+                               status = BT_FUNC_STATUS_ERROR;
                        } else {
-                               BT_LIB_LOGI(
+                               BT_LIB_LOGW(
                                        "Cannot decode Python plugin author string: "
                                        "py-plugin-info-addr=%p", plugin_info);
                                status = BT_FUNC_STATUS_NOT_FOUND;
@@ -416,9 +420,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                BT_LIB_LOGW_APPEND_CAUSE(
                                        "Cannot decode Python plugin description string: "
                                        "py-plugin-info-addr=%p", plugin_info);
-                               status = BT_FUNC_STATUS_LOADING_ERROR;
+                               status = BT_FUNC_STATUS_ERROR;
                        } else {
-                               BT_LIB_LOGI(
+                               BT_LIB_LOGW(
                                        "Cannot decode Python plugin description string: "
                                        "py-plugin-info-addr=%p", plugin_info);
                                status = BT_FUNC_STATUS_NOT_FOUND;
@@ -436,9 +440,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                BT_LIB_LOGW_APPEND_CAUSE(
                                        "Cannot decode Python plugin license string: "
                                        "py-plugin-info-addr=%p", plugin_info);
-                               status = BT_FUNC_STATUS_LOADING_ERROR;
+                               status = BT_FUNC_STATUS_ERROR;
                        } else {
-                               BT_LIB_LOGI(
+                               BT_LIB_LOGW(
                                        "Cannot decode Python plugin license string: "
                                        "py-plugin-info-addr=%p", plugin_info);
                                status = BT_FUNC_STATUS_NOT_FOUND;
@@ -477,9 +481,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                        BT_LIB_LOGW_APPEND_CAUSE(
                                                "Invalid Python plugin version format: "
                                                "py-plugin-info-addr=%p", plugin_info);
-                                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                                       status = BT_FUNC_STATUS_ERROR;
                                } else {
-                                       BT_LIB_LOGI(
+                                       BT_LIB_LOGW(
                                                "Invalid Python plugin version format: "
                                                "py-plugin-info-addr=%p", plugin_info);
                                        status = BT_FUNC_STATUS_NOT_FOUND;
@@ -502,9 +506,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                                BT_LIB_LOGW_APPEND_CAUSE(
                                                        "Cannot decode Python plugin version's extra string: "
                                                        "py-plugin-info-addr=%p", plugin_info);
-                                               status = BT_FUNC_STATUS_LOADING_ERROR;
+                                               status = BT_FUNC_STATUS_ERROR;
                                        } else {
-                                               BT_LIB_LOGI(
+                                               BT_LIB_LOGW(
                                                        "Cannot decode Python plugin version's extra string: "
                                                        "py-plugin-info-addr=%p", plugin_info);
                                                status = BT_FUNC_STATUS_NOT_FOUND;
@@ -558,9 +562,9 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                                "Component class address is not an integer in Python plugin info object: "
                                                "py-plugin-info-addr=%p, index=%zu",
                                                plugin_info, i);
-                                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                                       status = BT_FUNC_STATUS_ERROR;
                                } else {
-                                       BT_LIB_LOGI(
+                                       BT_LIB_LOGW(
                                                "Component class address is not an integer in Python plugin info object: "
                                                "py-plugin-info-addr=%p, index=%zu",
                                                plugin_info, i);
@@ -637,7 +641,9 @@ int bt_plugin_python_create_all_from_file(const char *path,
                 * Python plugins are disabled, so it's simply not
                 * found.
                 */
-               BT_LOGI_STR("Python plugin support was disabled previously because `BABELTRACE_DISABLE_PYTHON_PLUGINS=1`.");
+               BT_LOGI_STR("Python plugin support was disabled previously "
+                       "because the `LIBBABELTRACE2_DISABLE_PYTHON_PLUGINS` "
+                       "environment variable is set to `1`.");
                status = BT_FUNC_STATUS_NOT_FOUND;
                goto error;
        }
@@ -700,9 +706,9 @@ int bt_plugin_python_create_all_from_file(const char *path,
                        append_python_traceback_error_cause();
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Cannot load Python plugin: path=\"%s\"", path);
-                       status = BT_FUNC_STATUS_LOADING_ERROR;
+                       status = BT_FUNC_STATUS_ERROR;
                } else {
-                       BT_LIB_LOGI(
+                       BT_LIB_LOGW(
                                "Cannot load Python plugin: path=\"%s\"", path);
                        status = BT_FUNC_STATUS_NOT_FOUND;
                }
@@ -750,7 +756,7 @@ int bt_plugin_python_create_all_from_file(const char *path,
 
 error:
        BT_ASSERT(status != BT_FUNC_STATUS_OK);
-       log_python_traceback(fail_on_load_error ? BT_LOG_WARNING : BT_LOG_INFO);
+       log_python_traceback(BT_LOG_WARNING);
        pyerr_clear();
        BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out);
 
This page took 0.0305 seconds and 4 git commands to generate.