From a0cdfce8f136c825d057433ee6cf5b42b3421d3a Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 14 Jul 2019 22:45:56 -0400 Subject: [PATCH] plugins: log failure to load plugin as a warning In my experience writing a Python plugin, it is really helpful to see when it fails to load, with a traceback of the failure. We currently output this failure at the "info" level, which is not shown by default. Even if I set the log level to info, that failure is lost in a sea of messages. So, even if fail_on_load_error is false, a plugin that fails to load is a bit suspicious and is warn-worthy, in my opinion. Change-Id: I82844aaa62d33dc0ad1059d515ae1581356f4fe9 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1706 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/lib/plugin/plugin-so.c | 18 +++++------ .../python-plugin-provider.c | 32 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index a11798cc..319988be 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -409,7 +409,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, status = BT_FUNC_STATUS_LOADING_ERROR; goto end; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Ignoring unknown plugin descriptor attribute: " "plugin-path=\"%s\", plugin-name=\"%s\", " "attr-type-name=\"%s\", attr-type-id=%d", @@ -686,7 +686,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, status = BT_FUNC_STATUS_LOADING_ERROR; goto end; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Ignoring unknown component class descriptor attribute: " "plugin-path=\"%s\", " "plugin-name=\"%s\", " @@ -728,7 +728,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, status = init_status; goto end; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "User's plugin initialization function failed: " "status=%s", bt_common_func_status_string(init_status)); @@ -799,7 +799,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, status = BT_FUNC_STATUS_LOADING_ERROR; goto end; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Ignoring unknown component class type: " "plugin-path=\"%s\", plugin-name=\"%s\", " "comp-class-name=\"%s\", comp-class-type=%d", @@ -1335,7 +1335,7 @@ int bt_plugin_so_create_all_from_sections( status = BT_FUNC_STATUS_LOADING_ERROR; goto error; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Unknown ABI major version: abi-major=%d", descriptor->major); continue; @@ -1524,7 +1524,7 @@ int bt_plugin_so_create_all_from_file(const char *path, "__bt_get_end_section_plugin_descriptors"); status = BT_FUNC_STATUS_LOADING_ERROR; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Cannot resolve plugin symbol: path=\"%s\", " "symbol=\"%s\"", path, "__bt_get_end_section_plugin_descriptors"); @@ -1564,7 +1564,7 @@ int bt_plugin_so_create_all_from_file(const char *path, attrs_begin, attrs_end); status = BT_FUNC_STATUS_LOADING_ERROR; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Found section start or end symbol, but not both: " "path=\"%s\", symbol-start=\"%s\", " "symbol-end=\"%s\", symbol-start-addr=%p, " @@ -1608,7 +1608,7 @@ int bt_plugin_so_create_all_from_file(const char *path, cc_descriptors_begin, cc_descriptors_end); status = BT_FUNC_STATUS_LOADING_ERROR; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Found section start or end symbol, but not both: " "path=\"%s\", symbol-start=\"%s\", " "symbol-end=\"%s\", symbol-start-addr=%p, " @@ -1652,7 +1652,7 @@ int bt_plugin_so_create_all_from_file(const char *path, cc_descr_attrs_begin, cc_descr_attrs_end); status = BT_FUNC_STATUS_LOADING_ERROR; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Found section start or end symbol, but not both: " "path=\"%s\", symbol-start=\"%s\", " "symbol-end=\"%s\", symbol-start-addr=%p, " diff --git a/src/python-plugin-provider/python-plugin-provider.c b/src/python-plugin-provider/python-plugin-provider.c index 5bdcbfcd..a1324cff 100644 --- a/src/python-plugin-provider/python-plugin-provider.c +++ b/src/python-plugin-provider/python-plugin-provider.c @@ -252,7 +252,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -270,7 +270,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -288,7 +288,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -306,7 +306,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -324,7 +324,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -343,7 +343,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -362,7 +362,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -379,7 +379,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -398,7 +398,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -418,7 +418,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -438,7 +438,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -479,7 +479,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -504,7 +504,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "py-plugin-info-addr=%p", plugin_info); status = BT_FUNC_STATUS_LOADING_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; @@ -560,7 +560,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, plugin_info, i); status = BT_FUNC_STATUS_LOADING_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); @@ -702,7 +702,7 @@ int bt_plugin_python_create_all_from_file(const char *path, "Cannot load Python plugin: path=\"%s\"", path); status = BT_FUNC_STATUS_LOADING_ERROR; } else { - BT_LIB_LOGI( + BT_LIB_LOGW( "Cannot load Python plugin: path=\"%s\"", path); status = BT_FUNC_STATUS_NOT_FOUND; } @@ -750,7 +750,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); -- 2.34.1