lib: bt_plugin_find*(): return status code; add "fail on load error" param
[babeltrace.git] / src / lib / plugin / plugin.h
index d7f2d68fcbbc0d79685152f878a8e0bd8d915029..46b2b117be7b9b089db11687f2fad155c4c88b0f 100644 (file)
 #include "lib/object.h"
 #include <babeltrace2/types.h>
 #include "common/assert.h"
-#include "lib/lib-logging.h"
 #include <glib.h>
 
 #include "plugin-so.h"
 
+/* Protection: this file uses BT_LIB_LOG*() macros directly */
+#ifndef BT_LIB_LOG_SUPPORTED
+# error Please include "lib/logging.h" before including this file.
+#endif
+
 enum bt_plugin_type {
        BT_PLUGIN_TYPE_SO = 0,
        BT_PLUGIN_TYPE_PYTHON = 1,
 };
 
-enum bt_plugin_status {
-       BT_PLUGIN_STATUS_OK = 0,
-       BT_PLUGIN_STATUS_ERROR = -1,
-       BT_PLUGIN_STATUS_NOMEM = -12,
-};
-
 struct bt_plugin {
        struct bt_object base;
        enum bt_plugin_type type;
@@ -95,8 +93,12 @@ const char *bt_plugin_status_string(enum bt_plugin_status status)
        switch (status) {
        case BT_PLUGIN_STATUS_OK:
                return "BT_PLUGIN_STATUS_OK";
+       case BT_PLUGIN_STATUS_NOT_FOUND:
+               return "BT_PLUGIN_STATUS_NOT_FOUND";
        case BT_PLUGIN_STATUS_ERROR:
                return "BT_PLUGIN_STATUS_ERROR";
+       case BT_PLUGIN_STATUS_LOADING_ERROR:
+               return "BT_PLUGIN_STATUS_LOADING_ERROR";
        case BT_PLUGIN_STATUS_NOMEM:
                return "BT_PLUGIN_STATUS_NOMEM";
        default:
@@ -124,7 +126,7 @@ void bt_plugin_destroy(struct bt_object *obj)
 
        BT_ASSERT(obj);
        plugin = container_of(obj, struct bt_plugin, base);
-       BT_LIB_LOGD("Destroying plugin object: %!+l", plugin);
+       BT_LIB_LOGI("Destroying plugin object: %!+l", plugin);
 
        if (plugin->destroy_spec_data) {
                plugin->destroy_spec_data(plugin);
@@ -277,7 +279,7 @@ void bt_plugin_set_path(struct bt_plugin *plugin, const char *path)
        BT_ASSERT(path);
        g_string_assign(plugin->info.path, path);
        plugin->info.path_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, path=\"%s\"",
+       BT_LIB_LOGD("Set plugin's path: %![plugin-]+l, path=\"%s\"",
                plugin, path);
 }
 
@@ -288,7 +290,7 @@ void bt_plugin_set_name(struct bt_plugin *plugin, const char *name)
        BT_ASSERT(name);
        g_string_assign(plugin->info.name, name);
        plugin->info.name_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's name: %![plugin-]+l, name=\"%s\"",
+       BT_LIB_LOGD("Set plugin's name: %![plugin-]+l, name=\"%s\"",
                plugin, name);
 }
 
@@ -300,7 +302,7 @@ void bt_plugin_set_description(struct bt_plugin *plugin,
        BT_ASSERT(description);
        g_string_assign(plugin->info.description, description);
        plugin->info.description_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's description: %![plugin-]+l", plugin);
+       BT_LIB_LOGD("Set plugin's description: %![plugin-]+l", plugin);
 }
 
 static inline
@@ -310,7 +312,7 @@ void bt_plugin_set_author(struct bt_plugin *plugin, const char *author)
        BT_ASSERT(author);
        g_string_assign(plugin->info.author, author);
        plugin->info.author_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's author: %![plugin-]+l, author=\"%s\"",
+       BT_LIB_LOGD("Set plugin's author: %![plugin-]+l, author=\"%s\"",
                plugin, author);
 }
 
@@ -321,7 +323,7 @@ void bt_plugin_set_license(struct bt_plugin *plugin, const char *license)
        BT_ASSERT(license);
        g_string_assign(plugin->info.license, license);
        plugin->info.license_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, license=\"%s\"",
+       BT_LIB_LOGD("Set plugin's path: %![plugin-]+l, license=\"%s\"",
                plugin, license);
 }
 
@@ -339,7 +341,7 @@ void bt_plugin_set_version(struct bt_plugin *plugin, unsigned int major,
        }
 
        plugin->info.version_set = BT_TRUE;
-       BT_LIB_LOGV("Set plugin's version: %![plugin-]+l, "
+       BT_LIB_LOGD("Set plugin's version: %![plugin-]+l, "
                "major=%u, minor=%u, patch=%u, extra=\"%s\"",
                plugin, major, minor, patch, extra);
 }
@@ -435,7 +437,7 @@ void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set,
        BT_ASSERT(plugin);
        bt_object_get_ref(plugin);
        g_ptr_array_add(plugin_set->plugins, plugin);
-       BT_LIB_LOGV("Added plugin to plugin set: "
+       BT_LIB_LOGD("Added plugin to plugin set: "
                "plugin-set-addr=%p, %![plugin-]+l",
                plugin_set, plugin);
 }
This page took 0.044342 seconds and 4 git commands to generate.