plugin-loader: Reduce verbosity while loading plugins
[strongswan.git] / src / libstrongswan / plugins / plugin_loader.c
index 0549b37..828a620 100644 (file)
@@ -387,6 +387,35 @@ METHOD(plugin_loader_t, create_plugin_enumerator, enumerator_t*,
                                                        (void*)plugin_filter, NULL, NULL);
 }
 
+METHOD(plugin_loader_t, has_feature, bool,
+       private_plugin_loader_t *this, plugin_feature_t feature)
+{
+       enumerator_t *plugins, *features;
+       plugin_t *plugin;
+       linked_list_t *list;
+       plugin_feature_t *current;
+       bool found = FALSE;
+
+       plugins = create_plugin_enumerator(this);
+       while (plugins->enumerate(plugins, &plugin, &list))
+       {
+               features = list->create_enumerator(list);
+               while (features->enumerate(features, &current))
+               {
+                       if (plugin_feature_matches(&feature, current))
+                       {
+                               found = TRUE;
+                               break;
+                       }
+               }
+               features->destroy(features);
+               list->destroy(list);
+       }
+       plugins->destroy(plugins);
+
+       return found;
+}
+
 /**
  * Create a list of the names of all loaded plugins
  */
@@ -593,12 +622,12 @@ static bool load_dependencies(private_plugin_loader_t *this,
                        depend = plugin_feature_get_string(&provided->feature[i]);
                        if (soft)
                        {
-                               DBG2(DBG_LIB, "%*sfeature %s in plugin '%s' has unmet soft "
+                               DBG3(DBG_LIB, "%*sfeature %s in plugin '%s' has unmet soft "
                                         "dependency: %s", indent, "", provide, name, depend);
                        }
                        else
                        {
-                               DBG1(DBG_LIB, "feature %s in plugin '%s' has unmet dependency: "
+                               DBG2(DBG_LIB, "feature %s in plugin '%s' has unmet dependency: "
                                         "%s", provide, name, depend);
                        }
                        free(provide);
@@ -660,12 +689,12 @@ static void load_provided(private_plugin_loader_t *this,
        provide = plugin_feature_get_string(provided->feature);
        if (provided->loading)
        {       /* prevent loop */
-               DBG2(DBG_LIB, "%*sloop detected while loading %s in plugin '%s'",
+               DBG3(DBG_LIB, "%*sloop detected while loading %s in plugin '%s'",
                         indent, "", provide, name);
                free(provide);
                return;
        }
-       DBG2(DBG_LIB, "%*sloading feature %s in plugin '%s'",
+       DBG3(DBG_LIB, "%*sloading feature %s in plugin '%s'",
                 indent, "", provide, name);
        free(provide);
 
@@ -1085,6 +1114,7 @@ plugin_loader_t *plugin_loader_create()
                        .reload = _reload,
                        .unload = _unload,
                        .create_plugin_enumerator = _create_plugin_enumerator,
+                       .has_feature = _has_feature,
                        .loaded_plugins = _loaded_plugins,
                        .destroy = _destroy,
                },