diff options
author | Dan Winship <danw@gnome.org> | 2014-03-31 14:26:28 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-04-18 11:33:15 -0400 |
commit | 3b197de59fb330d6a1aa40f76e3e7b1c72686fd7 (patch) | |
tree | 1b1274d0a44fe63935205abf92e177557379dd49 /callouts | |
parent | 45ed459ae32976a120f607046021b48bf728c1d6 (diff) |
dispatcher: add better debugging
Add LOGD_DISPATCH, and if it's set to DEBUG, tell nm-dispatcher to log
additional information about each script it runs.
Diffstat (limited to 'callouts')
-rw-r--r-- | callouts/nm-dispatcher-action.c | 28 | ||||
-rw-r--r-- | callouts/nm-dispatcher.xml | 6 |
2 files changed, 30 insertions, 4 deletions
diff --git a/callouts/nm-dispatcher-action.c b/callouts/nm-dispatcher-action.c index 1a8c99fc00..23ae110772 100644 --- a/callouts/nm-dispatcher-action.c +++ b/callouts/nm-dispatcher-action.c @@ -83,6 +83,7 @@ impl_dispatch (Handler *h, const char *vpn_ip_iface, GHashTable *vpn_ip4_props, GHashTable *vpn_ip6_props, + gboolean request_debug, DBusGMethodInvocation *context); #include "nm-dispatcher-glue.h" @@ -116,6 +117,8 @@ struct Request { char *action; char *iface; char **envp; + gboolean debug; + GPtrArray *scripts; /* list of ScriptInfo */ guint idx; @@ -170,6 +173,11 @@ quit_timeout_reschedule (Handler *h) static void start_request (Request *request) { + if (request->iface) + g_message ("Dispatching action '%s' for %s", request->action, request->iface); + else + g_message ("Dispatching action '%s'", request->action); + request->handler->current_request = request; dispatch_one_script (request); } @@ -234,6 +242,13 @@ next_script (gpointer user_data) dbus_g_method_return (request->context, results); g_ptr_array_unref (results); + + if (request->debug) { + if (request->iface) + g_message ("Dispatch '%s' on %s complete", request->action, request->iface); + else + g_message ("Dispatch '%s' complete", request->action); + } request_free (request); next_request (h); @@ -271,7 +286,10 @@ script_watch_cb (GPid pid, gint status, gpointer user_data) script->script); } - if (script->result != DISPATCH_RESULT_SUCCESS) { + if (script->result == DISPATCH_RESULT_SUCCESS) { + if (script->request->debug) + g_message ("Script '%s' complete", script->script); + } else { script->result = DISPATCH_RESULT_FAILED; g_warning ("%s", script->error); } @@ -379,8 +397,8 @@ dispatch_one_script (Request *request) argv[2] = request->action; argv[3] = NULL; - if (debug) - g_message ("Script: %s %s %s", script->script, request->iface ? request->iface : "(none)", request->action); + if (request->debug) + g_message ("Running script '%s'", script->script); if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, child_setup, request, &script->pid, &error)) { request->script_watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script); @@ -451,6 +469,7 @@ impl_dispatch (Handler *h, const char *vpn_ip_iface, GHashTable *vpn_ip4_props, GHashTable *vpn_ip6_props, + gboolean request_debug, DBusGMethodInvocation *context) { GSList *sorted_scripts = NULL; @@ -470,6 +489,7 @@ impl_dispatch (Handler *h, request = g_malloc0 (sizeof (*request)); request->handler = h; + request->debug = request_debug || debug; request->context = context; request->action = g_strdup (str_action); @@ -486,7 +506,7 @@ impl_dispatch (Handler *h, vpn_ip6_props, &iface); - if (debug) { + if (request->debug) { g_message ("------------ Action ID %p '%s' Interface %s Environment ------------", context, str_action, iface ? iface : "(none)"); for (p = request->envp; *p; p++) diff --git a/callouts/nm-dispatcher.xml b/callouts/nm-dispatcher.xml index cba61508db..1ae138b35b 100644 --- a/callouts/nm-dispatcher.xml +++ b/callouts/nm-dispatcher.xml @@ -75,6 +75,12 @@ </tp:docstring> </arg> + <arg name="debug" type="b" direction="in"> + <tp:docstring> + Whether to log debug output. + </tp:docstring> + </arg> + <arg name="results" type="a(sus)" direction="out"> <tp:docstring> Results of dispatching operations. Each element of the returned |