plugin-loader: Add method to print loaded plugins on a given log level
authorTobias Brunner <tobias@strongswan.org>
Fri, 21 Jun 2013 12:45:38 +0000 (14:45 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 21 Jun 2013 13:17:53 +0000 (15:17 +0200)
src/charon-cmd/charon-cmd.c
src/charon-nm/charon-nm.c
src/charon-tkm/src/charon-tkm.c
src/charon/charon.c
src/conftest/conftest.c
src/frontends/android/jni/libandroidbridge/charonservice.c
src/libcharon/daemon.c
src/libstrongswan/plugins/plugin_loader.c
src/libstrongswan/plugins/plugin_loader.h
src/scepclient/scepclient.c

index f898fd6..d0e20f9 100644 (file)
@@ -361,6 +361,7 @@ int main(int argc, char *argv[])
        }
        DBG1(DBG_DMN, "Starting charon-cmd IKE client (strongSwan %s, %s %s, %s)",
                 VERSION, utsname.sysname, utsname.release, utsname.machine);
+       lib->plugins->status(lib->plugins, LEVEL_CTRL);
 
        /* add handler for SEGV and ILL,
         * INT, TERM and HUP are handled by sigwait() in run() */
index 61f2937..d61ddee 100644 (file)
@@ -212,6 +212,7 @@ int main(int argc, char *argv[])
                DBG1(DBG_DMN, "initialization failed - aborting charon-nm");
                goto deinit;
        }
+       lib->plugins->status(lib->plugins, LEVEL_CTRL);
 
        if (!charon->caps->drop(charon->caps))
        {
index 0b39058..4e364e7 100644 (file)
@@ -311,6 +311,7 @@ int main(int argc, char *argv[])
                DBG1(DBG_DMN, "initialization failed - aborting %s", dmn_name);
                goto deinit;
        }
+       lib->plugins->status(lib->plugins, LEVEL_CTRL);
 
        /* set global pidfile name depending on daemon name */
        if (asprintf(&pidfile_name, IPSEC_PIDDIR"/%s.pid", dmn_name) < 0)
index 812b762..eb7dd58 100644 (file)
@@ -398,6 +398,7 @@ int main(int argc, char *argv[])
                DBG1(DBG_DMN, "initialization failed - aborting charon");
                goto deinit;
        }
+       lib->plugins->status(lib->plugins, LEVEL_CTRL);
 
        if (check_pidfile())
        {
index c2251ef..56d98bb 100644 (file)
@@ -518,6 +518,8 @@ int main(int argc, char *argv[])
        {
                return 1;
        }
+       lib->plugins->status(lib->plugins, LEVEL_CTRL);
+
        if (!load_certs(conftest->test, conftest->suite_dir))
        {
                return 1;
index 370c52a..721c3a4 100644 (file)
@@ -565,6 +565,7 @@ JNI_METHOD(CharonVpnService, initializeCharon, void,
                library_deinit();
                return;
        }
+       lib->plugins->status(lib->plugins, LEVEL_CTRL);
 
        /* add handler for SEGV and ILL etc. */
        action.sa_handler = segv_handler;
index b27e177..70262b7 100644 (file)
@@ -538,8 +538,6 @@ METHOD(daemon_t, initialize, bool,
        {
                return FALSE;
        }
-       DBG1(DBG_DMN, "loaded plugins: %s",
-                lib->plugins->loaded_plugins(lib->plugins));
 
        this->public.ike_sa_manager = ike_sa_manager_create();
        if (this->public.ike_sa_manager == NULL)
index 2c8eae9..2631064 100644 (file)
@@ -1082,6 +1082,15 @@ METHOD(plugin_loader_t, loaded_plugins, char*,
        return this->loaded_plugins ?: "";
 }
 
+METHOD(plugin_loader_t, status, void,
+       private_plugin_loader_t *this, level_t level)
+{
+       if (this->loaded_plugins)
+       {
+               dbg(DBG_LIB, level, "loaded plugins: %s", this->loaded_plugins);
+       }
+}
+
 METHOD(plugin_loader_t, destroy, void,
        private_plugin_loader_t *this)
 {
@@ -1109,6 +1118,7 @@ plugin_loader_t *plugin_loader_create()
                        .create_plugin_enumerator = _create_plugin_enumerator,
                        .has_feature = _has_feature,
                        .loaded_plugins = _loaded_plugins,
+                       .status = _status,
                        .destroy = _destroy,
                },
                .plugins = linked_list_create(),
index 6bb9d6e..d4f74b9 100644 (file)
@@ -25,6 +25,7 @@
 typedef struct plugin_loader_t plugin_loader_t;
 
 #include <collections/enumerator.h>
+#include <utils/debug.h>
 
 /* to avoid circular references we can't include plugin_feature.h */
 struct plugin_feature_t;
@@ -110,6 +111,13 @@ struct plugin_loader_t {
        char* (*loaded_plugins)(plugin_loader_t *this);
 
        /**
+        * Log status about loaded plugins and features.
+        *
+        * @param level                 log level to use
+        */
+       void (*status)(plugin_loader_t *this, level_t level);
+
+       /**
         * Unload loaded plugins, destroy plugin_loader instance.
         */
        void (*destroy)(plugin_loader_t *this);
index 17f4d7c..11174c9 100644 (file)
@@ -929,8 +929,7 @@ int main(int argc, char **argv)
        {
                exit_scepclient("plugin loading failed");
        }
-       DBG1(DBG_APP, "  loaded plugins: %s",
-                lib->plugins->loaded_plugins(lib->plugins));
+       lib->plugins->status(lib->plugins, LEVEL_DIAG);
 
        if ((filetype_out == 0) && (!request_ca_certificate))
        {