plugin-loader: Move logging of failed features to status()
authorTobias Brunner <tobias@strongswan.org>
Fri, 21 Jun 2013 12:46:17 +0000 (14:46 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 21 Jun 2013 13:22:46 +0000 (15:22 +0200)
Still log an error message if critical features fail, as loaded
plugins/features are not logged in that case.

This way loaded plugins are printed before failed features and
the relation is easier to make for users.  It also allows programs
to log this message on a different level.

src/libstrongswan/plugins/plugin_loader.c

index 2631064..e08b123 100644 (file)
@@ -968,14 +968,11 @@ METHOD(plugin_loader_t, load_plugins, bool,
        if (!critical_failed)
        {
                load_features(this);
-               /* evaluate stats collected while loading the features */
-               critical_failed = this->stats.critical > 0;
-               if (this->stats.failed)
+               if (this->stats.critical > 0)
                {
-                       DBG1(DBG_LIB, "failed to load %d plugin feature%s (%d due to unmet "
-                                "dependencies, %d critical)", this->stats.failed,
-                                this->stats.failed == 1 ? "" : "s", this->stats.depends,
-                                this->stats.critical);
+                       critical_failed = TRUE;
+                       DBG1(DBG_LIB, "failed to load %d critical plugin feature%s",
+                                this->stats.critical, this->stats.critical == 1 ? "" : "s");
                }
                /* unload plugins that we were not able to load any features for */
                purge_plugins(this);
@@ -1088,6 +1085,13 @@ METHOD(plugin_loader_t, status, void,
        if (this->loaded_plugins)
        {
                dbg(DBG_LIB, level, "loaded plugins: %s", this->loaded_plugins);
+
+               if (this->stats.failed)
+               {
+                       dbg(DBG_LIB, level, "unable to load %d plugin feature%s (%d due to "
+                               "unmet dependencies)", this->stats.failed,
+                               this->stats.failed == 1 ? "" : "s", this->stats.depends);
+               }
        }
 }