diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index 70b1674f44..9fb956afc5 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -49,6 +49,7 @@ global: nm_client_new_finish; nm_client_permission_get_type; nm_client_permission_result_get_type; + nm_client_set_logging; nm_client_sleep; nm_client_wimax_get_enabled; nm_client_wimax_hardware_get_enabled; diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index aa7c08e374..62e5f835aa 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -1084,6 +1084,43 @@ nm_client_get_logging (NMClient *client, char **level, char **domains, GError ** return TRUE; } +/** + * nm_client_set_logging: + * @client: a #NMClient + * @level: (allow-none): logging level to set (%NULL or an empty string for no change) + * @domains: (allow-none): logging domains to set. The string should be a list of log + * domains separated by ",". (%NULL or an empty string for no change) + * @error: (allow-none): return location for a #GError, or %NULL + * + * Sets NetworkManager logging level and/or domains. + * + * Returns: %TRUE on success, %FALSE otherwise + **/ +gboolean +nm_client_set_logging (NMClient *client, const char *level, const char *domains, GError **error) +{ + GError *err = NULL; + + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (!level && !domains) + return TRUE; + + if (!dbus_g_proxy_call (NM_CLIENT_GET_PRIVATE (client)->client_proxy, "SetLogging", &err, + G_TYPE_STRING, level ? level : "", + G_TYPE_STRING, domains ? domains : "", + G_TYPE_INVALID, + G_TYPE_INVALID)) { + if (error) + *error = g_error_copy (err); + g_error_free (err); + return FALSE; + } + + return TRUE; +} + /****************************************************************/ static void diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h index e54f742e90..dadab6ab07 100644 --- a/libnm-glib/nm-client.h +++ b/libnm-glib/nm-client.h @@ -210,6 +210,7 @@ NMClientPermissionResult nm_client_get_permission_result (NMClient *client, NMClientPermission permission); gboolean nm_client_get_logging (NMClient *client, char **level, char **domain, GError **error); +gboolean nm_client_set_logging (NMClient *client, const char *level, const char *domain, GError **error); G_END_DECLS