From baf1541314e11b69c7faf6a3fcd05c1006695b51 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 26 Mar 2011 15:52:50 -0400 Subject: [PATCH] activation: Use _dbus_system_log for activation information Log when we are activating something (and whether it's via systemd) as well as when we fail to activate, and when one succeeds. --- bus/activation.c | 87 +++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 70 insertions(+), 17 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index ab6ef51..9cad01f 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -1106,6 +1106,10 @@ bus_activation_service_created (BusActivation *activation, if (!pending_activation) return TRUE; + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Successfully activated service '%s'", + service_name); + link = _dbus_list_get_first_link (&pending_activation->entries); while (link != NULL) { @@ -1400,6 +1404,11 @@ babysitter_watch_callback (DBusWatch *watch, if (activation_failed) { + bus_context_log (pending_activation->activation->context, + DBUS_SYSTEM_LOG_INFO, "Activated service '%s' failed: %s", + pending_activation->service_name, + error.message); + /* Destroy all pending activations with the same exec */ _dbus_hash_iter_init (pending_activation->activation->pending_activations, &iter); @@ -1462,6 +1471,10 @@ pending_activation_timed_out (void *data) dbus_set_error (&error, DBUS_ERROR_TIMED_OUT, "Activation of %s timed out", pending_activation->service_name); + bus_context_log (pending_activation->activation->context, + DBUS_SYSTEM_LOG_INFO, + "Failed to activate service '%s': timed out", + pending_activation->service_name); pending_activation_failed (pending_activation, &error); @@ -1714,6 +1727,10 @@ bus_activation_activate_service (BusActivation *activation, { dbus_uint32_t result; + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Service '%s' is already active", + service_name); + _dbus_verbose ("Service \"%s\" is already active\n", service_name); message = dbus_message_new_method_return (activation_message); @@ -1962,18 +1979,34 @@ bus_activation_activate_service (BusActivation *activation, service = bus_registry_lookup (registry, &service_string); if (service != NULL) - /* Wonderful, systemd is connected, let's just send the msg */ - retval = bus_dispatch_matches (activation_transaction, NULL, bus_service_get_primary_owners_connection (service), - message, error); + { + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Activating via systemd service name='%s' unit='%s'", + service_name, + entry->systemd_service); + /* Wonderful, systemd is connected, let's just send the msg */ + retval = bus_dispatch_matches (activation_transaction, NULL, bus_service_get_primary_owners_connection (service), + message, error); + } else - /* systemd is not around, let's "activate" it. */ - retval = bus_activation_activate_service (activation, connection, activation_transaction, TRUE, - message, "org.freedesktop.systemd1", error); + { + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Activating systemd to hand-off service name='%s' unit='%s'", + service_name, + entry->systemd_service); + /* systemd is not around, let's "activate" it. */ + retval = bus_activation_activate_service (activation, connection, activation_transaction, TRUE, + message, "org.freedesktop.systemd1", error); + } dbus_message_unref (message); if (!retval) { + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Failed to activate via systemd service name='%s' unit='%s'", + service_name, + entry->systemd_service); _DBUS_ASSERT_ERROR_IS_SET (error); _dbus_verbose ("failed to send activation message: %s\n", error->name); bus_transaction_cancel_and_free (activation_transaction); @@ -2069,18 +2102,32 @@ bus_activation_activate_service (BusActivation *activation, } _dbus_verbose ("Spawning %s ...\n", argv[0]); - if (!_dbus_spawn_async_with_babysitter (&pending_activation->babysitter, argv, - envp, - NULL, activation, - error)) - { - _dbus_verbose ("Failed to spawn child\n"); - _DBUS_ASSERT_ERROR_IS_SET (error); - dbus_free_string_array (argv); - dbus_free_string_array (envp); + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Activating service name='%s' argv0='%s'", + service_name, + argv[0]); + { + DBusError tmp_error; + dbus_error_init (&tmp_error); + + if (!_dbus_spawn_async_with_babysitter (&pending_activation->babysitter, argv, + envp, + NULL, activation, + &tmp_error)) + { + _dbus_verbose ("Failed to spawn child\n"); + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Failed to activate service %s: %s", + service_name, + tmp_error.message); + _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); + dbus_move_error (&tmp_error, error); + dbus_free_string_array (argv); + dbus_free_string_array (envp); - return FALSE; - } + return FALSE; + } + } dbus_free_string_array (argv); envp = NULL; @@ -2166,10 +2213,16 @@ dbus_activation_systemd_failure (BusActivation *activation, DBUS_TYPE_INVALID)) dbus_set_error(&error, code, str); + if (unit) { DBusHashIter iter; + bus_context_log (activation->context, + DBUS_SYSTEM_LOG_INFO, "Activation via systemd failed for unit '%s': %s", + unit, + str); + _dbus_hash_iter_init (activation->pending_activations, &iter); -- 1.7.4.1