GOptionContext *context;
LAHandler *service;
GError *error = NULL;
- gchar *msg;
/* register the application and context with the DLT */
DLT_REGISTER_APP ("NSC", "GENIVI Node Startup Controller");
if (!g_option_context_parse (context, &argc, &argv, &error))
{
/* parsing failed, exit with an error */
- msg = g_strdup_printf ("Failed to parse command line options: %s\n",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to parse command line options: "),
+ DLT_STRING (error->message));
/* clean up */
g_option_context_free (context);
|| ((shutdown_mode & NSM_SHUTDOWN_TYPE_NORMAL) == 0
&& (shutdown_mode & NSM_SHUTDOWN_TYPE_FAST) == 0))
{
- msg = g_strdup_printf ("Failed to register legacy application: "
- "invalid shutdown mode \"0x%x\"", shutdown_mode);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register legacy application: "),
+ DLT_STRING ("invalid shutdown mode \"0x%x\""),
+ DLT_UINT (shutdown_mode));
/* free command line options */
g_free (unit);
NULL, &error);
/* abort if the proxy could not be created */
- if (service == NULL)
+ if (error != NULL)
{
- msg = g_strdup_printf ("Failed to register legacy application: %s", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register legacy application: "),
+ DLT_STRING (error->message));
/* clean up */
g_error_free (error);
if (!la_handler_call_register_sync (service, unit, shutdown_mode, timeout,
NULL, &error))
{
- msg = g_strdup_printf ("Failed to register legacy application: %s", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register legacy application: "),
+ DLT_STRING (error->message));
/* clean up */
g_error_free (error);
{
LAHandlerService *service = LA_HANDLER_SERVICE (object);
GError *error = NULL;
- gchar *log_text;
/* connect to the node state manager */
service->nsm_consumer =
NULL, &error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Error occurred connecting to NSM Consumer: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to connect to the NSM consumer: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
}
const gchar *existing_bus_name;
const gchar *existing_object_path;
gchar *bus_name;
- gchar *log_text;
gchar *object_path;
g_return_val_if_fail (IS_LA_HANDLER (interface), FALSE);
service->connection, object_path, &error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to export shutdown consumer on the bus: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to export shutdown consumer on the bus: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
LAHandlerService *service;
NSMConsumer *nsm_consumer = NSM_CONSUMER (object);
GError *error = NULL;
- gchar *log_text;
gint error_code;
g_return_if_fail (IS_NSM_CONSUMER (nsm_consumer));
&error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to register a shutdown consumer: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register a shutdown consumer: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
{
LAHandlerServiceData *data = (LAHandlerServiceData *)user_data;
GError *err = NULL;
- gchar *log_text;
gint error_status = NSM_ERROR_STATUS_OK;
gint status = NSM_ERROR_STATUS_OK;
g_return_if_fail (data != NULL);
/* log that we are completing a lifecycle request */
- log_text = g_strdup_printf ("Completing lifecycle request: request id %u",
- data->request_id);
- DLT_LOG (la_handler_context, DLT_LOG_INFO, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_INFO,
+ DLT_STRING ("Completing a lifecycle request: request id "),
+ DLT_UINT (data->request_id));
/* log an error if shutting down the consumer has failed */
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to shutdown a shutdown consumer: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to shut down a shutdown consumer: "),
+ DLT_STRING (error->message));
/* send an error back to the NSM */
status = NSM_ERROR_STATUS_ERROR;
data->request_id, status,
&error_status, NULL, &err))
{
- log_text = g_strdup_printf ("Failed to notify Node State Manager about completed "
- "lifecycle request: request id %u: %s",
- data->request_id, err->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to notify NSM about completed lifecycle request: "),
+ DLT_STRING ("request id "), DLT_UINT (data->request_id),
+ DLT_STRING (": "), DLT_STRING (error->message));
g_error_free (err);
}
else if (error_status == NSM_ERROR_STATUS_OK)
{
- log_text = g_strdup_printf ("Successfully notified Node State Manager about "
- "completed lifecycle request: request id %u",
- data->request_id);
- DLT_LOG (la_handler_context, DLT_LOG_INFO, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_INFO,
+ DLT_STRING ("Successfully notified NSM about completed lifecycle request: "),
+ DLT_STRING ("request id "), DLT_UINT (data->request_id));
}
else
{
- log_text = g_strdup_printf ("Failed to notify Node State Manager about completed "
- "lifecycle request: request id %u, error status %u",
- data->request_id, error_status);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to notify NSM about completed lifecycle request: "),
+ DLT_STRING ("request id "), DLT_UINT (data->request_id),
+ DLT_STRING (", error status "), DLT_INT (error_status));
}
la_handler_service_data_unref (data);
const gchar *object_path;
const gchar *unit;
GError *error = NULL;
- gchar *log_text;
gint error_code;
gint shutdown_mode;
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to unregister shutdown client %s "
- "for unit %s: %s", object_path, unit,
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to unregister shutdown client "),
+ DLT_STRING (object_path), DLT_STRING (" for unit "), DLT_STRING (unit),
+ DLT_STRING (": "), DLT_STRING (error->message));
g_error_free (error);
}
else if (error_code != NSM_ERROR_STATUS_OK)
{
- log_text = g_strdup_printf ("Failed to unregister shutdown client %s "
- "for unit %s: error code %d", object_path, unit,
- error_code);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to unregister shutdown client "),
+ DLT_STRING (object_path), DLT_STRING (" for unit "), DLT_STRING (unit),
+ DLT_STRING (": error code "), DLT_INT (error_code));
}
}
}
LUCStarter *starter = LUC_STARTER (object);
GError *error = NULL;
gchar **types;
- gchar *log_text;
guint n;
gint type;
NULL, &error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to connect to the NSM lifecycle control: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to connect to the NSM lifecycle control: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
LUCStarter *starter = LUC_STARTER (user_data);
GPtrArray *apps;
gboolean app_found = FALSE;
- gchar *message;
guint n;
gint group;
/* respond to errors */
if (error != NULL)
{
- message = g_strdup_printf ("Failed to start the LUC application \"%s\": %s",
- unit, error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to start the LUC application \""),
+ DLT_STRING (unit), DLT_STRING ("\": "), DLT_STRING (error->message));
}
/* get the current start group */
LUCStarter *starter = LUC_STARTER (user_data);
gboolean luc_required = TRUE;
GError *error = NULL;
- gchar *log_text;
g_return_if_fail (IS_NSM_LIFECYCLE_CONTROL (nsm_lifecycle_control));
g_return_if_fail (G_IS_ASYNC_RESULT (res));
if (!nsm_lifecycle_control_call_check_luc_required_finish (nsm_lifecycle_control,
&luc_required, res, &error))
{
- log_text = g_strdup_printf ("Failed checking whether the LUC is required: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to check whether the LUC is required: "),
+ DLT_STRING (error->message));
g_clear_error (&error);
DLT_LOG (controller_context, DLT_LOG_INFO,
GList *groups;
GList *lp;
gchar **apps;
- gchar *log_text;
guint n;
gint group;
gint type;
&error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Error reading last user context: %s", error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to read the last user context: "),
+ DLT_STRING (error->message));
g_error_free (error);
return;
}
JobManager *job_manager;
GMainLoop *main_loop;
GError *error = NULL;
- gchar *msg;
/* register the application and context in DLT */
DLT_REGISTER_APP ("NSC", "GENIVI Node Startup Controller");
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (connection == NULL)
{
- msg = g_strdup_printf ("Failed to connect to the system bus: %s", error->message);
- DLT_LOG (controller_context, DLT_LOG_FATAL, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (controller_context, DLT_LOG_FATAL,
+ DLT_STRING ("Failed to connect to the system bus: "),
+ DLT_STRING (error->message));
/* clean up */
g_error_free (error);
NULL, &error);
if (systemd_manager == NULL)
{
- msg = g_strdup_printf ("Failed to connect to the systemd manager: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_FATAL, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (controller_context, DLT_LOG_FATAL,
+ DLT_STRING ("Failed to connect to the systemd manager: "),
+ DLT_STRING (error->message));
/* clean up */
g_error_free (error);
/* subscribe to the systemd manager */
if (!systemd_manager_call_subscribe_sync (systemd_manager, NULL, &error))
{
- msg = g_strdup_printf ("Failed to subscribe to the systemd manager: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_FATAL, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (controller_context, DLT_LOG_FATAL,
+ DLT_STRING ("Failed to subscribe to the systemd manager: "),
+ DLT_STRING (error->message));
/* clean up */
g_error_free (error);
/* attempt to start the node startup controller service */
if (!node_startup_controller_service_start_up (node_startup_controller, &error))
{
- msg = g_strdup_printf ("Failed to start the node startup controller service: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to start the node startup controller service: "),
+ DLT_STRING (error->message));
/* clean up */
g_error_free (error);
/* start the legacy app handler */
if (!la_handler_service_start (la_handler_service, &error))
{
- msg = g_strdup_printf ("Failed to start the legacy app handler service: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (msg));
- g_free (msg);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to start the legacy app handler service: "),
+ DLT_STRING (error->message));
/* clean up */
g_clear_error (&error);
const gchar *watchdog_str;
guint64 watchdog_usec = 0;
guint watchdog_sec = 0;
- gchar *message;
/* read the WATCHDOG_USEC environment variable and parse it
* into an unsigned integer */
application->watchdog_client = watchdog_client_new (watchdog_sec);
/* log information about the watchdog timeout using DLT */
- message = g_strdup_printf ("Updating systemd's watchdog timestamp every %d seconds",
- watchdog_sec);
- DLT_LOG (controller_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (controller_context, DLT_LOG_INFO,
+ DLT_STRING ("Updating the systemd watchdog timestamp every "),
+ DLT_UINT (watchdog_sec), DLT_STRING (" seconds"));
}
}
NSMConsumer *nsm_consumer;
GError *error = NULL;
gchar *bus_name = "org.genivi.NodeStartupController1";
- gchar *log_text;
gchar *object_path;
gint timeout;
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (consumer),
application->connection, object_path, &error))
{
- log_text = g_strdup_printf ("Failed to export shutdown consumer on the bus: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to export shutdown consumer on the bus: "),
+ DLT_STRING (error->message));
g_clear_error (&error);
}
{
NSMConsumer *nsm_consumer = NSM_CONSUMER (object);
GError *error = NULL;
- gchar *log_text;
gint error_code = NSM_ERROR_STATUS_OK;
g_return_if_fail (IS_NSM_CONSUMER (nsm_consumer));
if (!nsm_consumer_call_register_shutdown_client_finish (nsm_consumer, &error_code, res,
&error))
{
- log_text = g_strdup_printf ("Failed to register the node startup controller as a shutdown "
- "consumer: %s", error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register the node startup controller "
+ "as a shutdown consumer: "), DLT_STRING (error->message));
g_error_free (error);
}
else if (error_code == NSM_ERROR_STATUS_OK)
{
- log_text = g_strdup_printf ("The node startup controller has registered as a shutdown "
- "consumer");
- DLT_LOG (controller_context, DLT_LOG_INFO, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_INFO,
+ DLT_STRING ("Successfully registered the node startup controller "
+ "as a shutdown consumer"));
}
else
{
- log_text = g_strdup_printf ("Failed to register the node startup controller as a shutdown "
- "consumer: error status %d", error_code);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register the node startup controller "
+ "as a shutdown consumer: error status "),
+ DLT_INT (error_code));
}
}
NodeStartupControllerApplication *application = NODE_STARTUP_CONTROLLER_APPLICATION (user_data);
NSMConsumer *nsm_consumer = NSM_CONSUMER (object);
GError *error = NULL;
- gchar *log_text;
gint error_code = NSM_ERROR_STATUS_OK;
g_return_if_fail (IS_NSM_CONSUMER (nsm_consumer));
if (!nsm_consumer_call_un_register_shutdown_client_finish (nsm_consumer, &error_code,
res, &error))
{
- log_text = g_strdup_printf ("Failed to unregister the node startup controller as a shutdown "
- "consumer: %s", error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to unregister the node startup controller "
+ "as a shutdown consumer: "), DLT_STRING (error->message));
g_error_free (error);
}
else if (error_code == NSM_ERROR_STATUS_OK)
{
- log_text = g_strdup_printf ("The node startup controller has unregistered as a shutdown "
- "consumer");
- DLT_LOG (controller_context, DLT_LOG_INFO, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_INFO,
+ DLT_STRING ("Successfully unregistered the node startup controller "
+ "as a shutdown consumer"));
}
else
{
- log_text = g_strdup_printf ("Failed to unregister the node startup controller as a shutdown "
- "consumer: error status %d", error_code);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to unregister the node startup controller "
+ "as a shutdown consumer: error status "),
+ DLT_INT (error_code));
}
/* quit the application */
NodeStartupControllerService *service)
{
GError *error = NULL;
- gchar *log_text;
g_return_val_if_fail (IS_NODE_STARTUP_CONTROLLER (interface), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
/* check if last user context registration started */
if (!service->started_registration)
{
- log_text = g_strdup_printf ("Failed to finish LUC registration: "
- "the registration sequence has not been started yet");
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to finish the LUC registration: "
+ "the registration sequence was not started properly"));
/* notify the caller that we have handled the method call */
g_dbus_method_invocation_return_value (invocation, NULL);
node_startup_controller_service_write_luc (service, &error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to finish LUC registration: %s", error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to finish the LUC registration: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
GList *luc_types;
gchar *app;
gchar *debug_text = NULL;
- gchar *log_text = NULL;
guint n;
gint luc_type;
/* check if last user context registration started */
if (!service->started_registration)
{
- log_text = g_strdup_printf ("Failed to register apps with the LUC: "
- "The registration sequence has not been started yet");
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register apps with the LUC: "
+ "the registration sequence was not started properly"));
/* notify the caller that we have handled the register request */
g_dbus_method_invocation_return_value (invocation, NULL);
/* log the new last user context */
debug_text = g_variant_print (service->current_user_context, TRUE);
- log_text = g_strdup_printf ("The new context is: %s", debug_text);
- DLT_LOG (controller_context, DLT_LOG_DEBUG, DLT_STRING (log_text));
+ DLT_LOG (controller_context, DLT_LOG_DEBUG,
+ DLT_STRING ("New LUC is: "), DLT_STRING (debug_text));
g_free (debug_text);
- g_free (log_text);
/* release the current context */
g_variant_unref (current_context);
static void
target_startup_monitor_init (TargetStartupMonitor *monitor)
{
- GError *error = NULL;
- gchar *log_text;
+ GError *error = NULL;
/* create proxy to talk to the Node State Manager's lifecycle control */
monitor->nsm_lifecycle_control =
NULL, &error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to connect to the NSM lifecycle control: %s",
- error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to connect to the NSM lifecycle control: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
{
GetUnitData *data = user_data;
GError *error = NULL;
- gchar *message;
gchar *object_path;
g_return_if_fail (IS_SYSTEMD_MANAGER (object));
res, &error))
{
/* there was an error, log it */
- message = g_strdup_printf ("Failed to get unit \"%s\" from systemd: %s",
- data->unit_name, error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to get unit \""), DLT_STRING (data->unit_name),
+ DLT_STRING ("\" from systemd: "), DLT_STRING (error->message));
g_error_free (error);
/* release the get unit data */
}
else
{
- message = g_strdup_printf ("Creating D-Bus proxy for unit \"%s\"", object_path);
- DLT_LOG (controller_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (controller_context, DLT_LOG_INFO,
+ DLT_STRING ("Creating D-Bus proxy for unit \""), DLT_STRING (object_path),
+ DLT_STRING ("\""));
/* remember the object path */
data->object_path = object_path;
const gchar *state;
gpointer node_state;
GError *error = NULL;
- gchar *message;
g_return_if_fail (G_IS_ASYNC_RESULT (res));
g_return_if_fail (data != NULL);
if (error != NULL)
{
/* there was an error, log it */
- message = g_strdup_printf ("Failed to create a D-Bus proxy for unit \"%s\": %s",
- data->object_path, error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (message));
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to create D-Bus proxy for unit \""),
+ DLT_STRING (data->object_path), DLT_STRING ("\": "),
+ DLT_STRING (error->message));
g_error_free (error);
}
else
state = systemd_unit_get_active_state (unit);
/* log the the active state has changed */
- message = g_strdup_printf ("Active state of unit \"%s\" changed to %s",
- data->unit_name, state);
- DLT_LOG (controller_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (controller_context, DLT_LOG_INFO,
+ DLT_STRING ("Active state of unit \""), DLT_STRING (data->unit_name),
+ DLT_STRING ("\" changed to "), DLT_STRING (state));
/* check if the new state is active */
if (g_strcmp0 (state, "active") == 0)
{
NSMLifecycleControl *nsm_lifecycle_control = NSM_LIFECYCLE_CONTROL (object);
GError *error = NULL;
- gchar *log_text;
NSMErrorStatus error_code = NSM_ERROR_STATUS_OK;
g_return_if_fail (IS_NSM_LIFECYCLE_CONTROL (nsm_lifecycle_control));
(gint *) &error_code, res,
&error))
{
- log_text = g_strdup_printf ("Failed to set the node state: %s", error->message);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to set the node state: "),
+ DLT_STRING (error->message));
g_error_free (error);
}
else if (error_code != NSM_ERROR_STATUS_OK)
{
- log_text = g_strdup_printf ("Failed to set the node state: error code %d",
- error_code);
- DLT_LOG (controller_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
+ DLT_LOG (controller_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to set the node state: error code "),
+ DLT_UINT (error_code));
}
}
const gchar *current_object_path;
GError *error = NULL;
GList *lp;
- gchar *message;
g_return_val_if_fail (IS_NSM_CONSUMER (object), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (consumer), timeout);
/* log information about the re-registration */
- message = g_strdup_printf ("Re-registered shutdown client: bus name %s, "
- "object path %s, new shutdown mode %d, new timeout %d",
- bus_name, object_path,
- shutdown_client_get_shutdown_mode (shutdown_client),
- shutdown_client_get_timeout (shutdown_client));
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Re-registered shutdown client: "),
+ DLT_STRING ("bus name "), DLT_STRING (bus_name),
+ DLT_STRING (", object path "), DLT_STRING (object_path),
+ DLT_STRING (", new shutdown mode "),
+ DLT_UINT (shutdown_client_get_shutdown_mode (shutdown_client)),
+ DLT_STRING (", new timeout "),
+ DLT_UINT (shutdown_client_get_timeout (shutdown_client)));
}
else
{
if (error != NULL)
{
/* log the error */
- message = g_strdup_printf ("Failed to register shutdown client %s: %s",
- object_path, error->message);
- DLT_LOG (nsm_dummy_context, DLT_LOG_ERROR, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to register shutdown client "),
+ DLT_STRING (object_path), DLT_STRING (": "),
+ DLT_STRING (error->message));
g_error_free (error);
/* report the error back to the caller */
shutdown_client);
/* log the registered shutdown client */
- message = g_strdup_printf ("Shutdown client registered: bus name %s, "
- "object path %s, shutdown mode: %d, timeout: %d",
- bus_name, object_path, shutdown_mode, timeout);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Shutdown client registered: "),
+ DLT_STRING ("bus name "), DLT_STRING (bus_name),
+ DLT_STRING (", object path "), DLT_STRING (object_path),
+ DLT_STRING (", shutdown mode "), DLT_UINT (shutdown_mode),
+ DLT_STRING (", timeout "), DLT_UINT (timeout));
/* release the consumer proxy; the client owns it now */
g_object_unref (consumer);
GList *lp;
const gchar *current_bus_name;
const gchar *current_object_path;
- gchar *message;
g_return_val_if_fail (IS_NSM_CONSUMER (object), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
if (shutdown_client_get_shutdown_mode (shutdown_client) == 0)
{
/* log the unregistration now */
- message = g_strdup_printf ("Shutdown client unregistered: "
- "bus name %s, object path %s",
- bus_name, object_path);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Shutdown client unregistered: "),
+ DLT_STRING ("bus name "), DLT_STRING (bus_name),
+ DLT_STRING (", object path "), DLT_STRING (object_path));
/* remove the client from the list of registered clients */
service->shutdown_clients = g_list_remove (service->shutdown_clients,
NSMErrorStatus status,
NSMConsumerService *service)
{
- gchar *message;
-
g_return_val_if_fail (IS_NSM_CONSUMER (object), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
g_return_val_if_fail (NSM_CONSUMER_IS_SERVICE (service), FALSE);
- message = g_strdup_printf ("Finished shutting down a client: "
- "request id %d, status %d", request_id, status);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Finished shutting down client: "),
+ DLT_STRING ("request id "), DLT_UINT (request_id),
+ DLT_STRING (", status "), DLT_UINT (status));
nsm_consumer_complete_lifecycle_request_complete (object, invocation,
NSM_ERROR_STATUS_OK);
else
{
/* no we haven't; log this as a warning */
- message = g_strdup_printf ("Waiting for lifecycle request %d to be "
- "completed but received completion of %d "
- "instead",
- service->shutdown_queue->timeout_request,
- request_id);
- DLT_LOG (nsm_dummy_context, DLT_LOG_WARN, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_WARN,
+ DLT_STRING ("Waiting for lifecycle request "),
+ DLT_UINT (service->shutdown_queue->timeout_request),
+ DLT_STRING (" to be completed but received completion of "),
+ DLT_UINT (request_id),
+ DLT_STRING ("instead "));
}
}
else
{
/* the timeout is no longer active, we might have missed
* the time window; log this now */
- message = g_strdup_printf ("Lifecycle request %d completed too late",
- request_id);
- DLT_LOG (nsm_dummy_context, DLT_LOG_WARN, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_WARN,
+ DLT_STRING ("Lifecycle request "), DLT_UINT (request_id),
+ DLT_STRING (" completed too late"));
}
}
{
ShutdownConsumer *consumer;
ShutdownClient *client;
- gchar *message;
g_return_if_fail (NSM_CONSUMER_IS_SERVICE (service));
g_return_if_fail (service->shutdown_queue != NULL);
if ((shutdown_client_get_shutdown_mode (client)
& service->shutdown_queue->current_mode) != 0)
{
- message = g_strdup_printf ("Shutting down a client: "
- "bus name %s, object path %s, "
- "shutdown mode %d, timeout %d, "
- "request id %d",
- shutdown_client_get_bus_name (client),
- shutdown_client_get_object_path (client),
- shutdown_client_get_shutdown_mode (client),
- shutdown_client_get_timeout (client),
- GPOINTER_TO_UINT (client));
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Shutting down a client: "),
+ DLT_STRING ("bus name "),
+ DLT_STRING (shutdown_client_get_bus_name (client)),
+ DLT_STRING (", object path "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (", shutdown mode "),
+ DLT_UINT (shutdown_client_get_shutdown_mode (client)),
+ DLT_STRING (", timeout "),
+ DLT_UINT (shutdown_client_get_timeout (client)),
+ DLT_STRING (", request id "),
+ DLT_UINT (GPOINTER_TO_UINT (client)));
/* get the consumer associated with the shutdown client */
consumer = shutdown_client_get_consumer (client);
}
else
{
- message = g_strdup_printf ("Skipping %s: it is not registered for this "
- "shutdown mode",
- shutdown_client_get_object_path (client));
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Skipping client "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (": it is not registered for shutdown mode "),
+ DLT_UINT (service->shutdown_queue->current_mode));
/* it isn't, so remove it from the queue */
service->shutdown_queue->remaining_clients =
ShutdownClient *client;
NSMErrorStatus error_code;
GError *error = NULL;
- gchar *message;
g_return_if_fail (IS_SHUTDOWN_CONSUMER (consumer));
g_return_if_fail (G_IS_ASYNC_RESULT (res));
res, &error))
{
/* log the error */
- message = g_strdup_printf ("Failed to shut down client %s: %s",
- shutdown_client_get_object_path (client),
- error->message);
- DLT_LOG (nsm_dummy_context, DLT_LOG_ERROR, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_ERROR,
+ DLT_STRING ("Failed to shut down client "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (": "), DLT_STRING (error->message));
g_clear_error (&error);
/* remove the client it from the shutdown queue */
else if (error_code == NSM_ERROR_STATUS_OK)
{
/* log the successful shutdown */
- message = g_strdup_printf ("Client shut down successfully: bus name %s, "
- "object path %s, shutdown mode: %d",
- shutdown_client_get_bus_name (client),
- shutdown_client_get_object_path (client),
- service->shutdown_queue->current_mode);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Successfully shut down client: "),
+ DLT_STRING ("bus name "),
+ DLT_STRING (shutdown_client_get_bus_name (client)),
+ DLT_STRING (", object path "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (", shutdown mode "),
+ DLT_UINT (service->shutdown_queue->current_mode));
/* remove the client it from the shutdown queue */
service->shutdown_queue->remaining_clients =
else if (error_code == NSM_ERROR_STATUS_RESPONSE_PENDING)
{
/* log that we are waiting for the client to finish its shutdown */
- message = g_strdup_printf ("Waiting for client to shut down: "
- "request id: %d, bus name %s, "
- "object path %s, shutdown mode: %d",
- GPOINTER_TO_UINT (client),
- shutdown_client_get_bus_name (client),
- shutdown_client_get_object_path (client),
- service->shutdown_queue->current_mode);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Waiting for client to shut down: "),
+ DLT_STRING ("request id "),
+ DLT_UINT (GPOINTER_TO_UINT (client)),
+ DLT_STRING (", bus name "),
+ DLT_STRING (shutdown_client_get_bus_name (client)),
+ DLT_STRING (", object path "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (", shutdown mode "),
+ DLT_UINT (service->shutdown_queue->current_mode));
/* start a timeout to wait for LifecycleComplete to be called by the
* client we just asked to shut down */
else
{
/* log that shutting down this client failed */
- message = g_strdup_printf ("Failed shutting down a client: "
- "request id: %d, bus name %s, "
- "object path %s, shutdown mode: %d, "
- "error status %d",
- GPOINTER_TO_UINT (client),
- shutdown_client_get_bus_name (client),
- shutdown_client_get_object_path (client),
- service->shutdown_queue->current_mode,
- error_code);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Failed shutting down a client: "),
+ DLT_STRING ("request id "),
+ DLT_UINT (GPOINTER_TO_UINT (client)),
+ DLT_STRING (", bus name "),
+ DLT_STRING (shutdown_client_get_bus_name (client)),
+ DLT_STRING (", object path "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (", shutdown mode "),
+ DLT_UINT (service->shutdown_queue->current_mode),
+ DLT_STRING (", error status "),
+ DLT_UINT (error_code));
/* remove the client it from the shutdown queue */
service->shutdown_queue->remaining_clients =
{
NSMConsumerService *service = NSM_CONSUMER_SERVICE (user_data);
ShutdownClient *client;
- gchar *message;
g_return_val_if_fail (NSM_CONSUMER_IS_SERVICE (service), FALSE);
* for to shut down */
if (service->shutdown_queue->timeout_request == GPOINTER_TO_UINT (client))
{
- message = g_strdup_printf ("Received timeout while shutting down a client: "
- "bus name %s, object path %s, shutdown mode %d, "
- "timeout %d, request id %d",
- shutdown_client_get_bus_name (client),
- shutdown_client_get_object_path (client),
- shutdown_client_get_shutdown_mode (client),
- shutdown_client_get_timeout (client),
- service->shutdown_queue->timeout_request);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Received timeout while shutting down a client: "),
+ DLT_STRING ("bus name "),
+ DLT_STRING (shutdown_client_get_bus_name (client)),
+ DLT_STRING (", object path "),
+ DLT_STRING (shutdown_client_get_object_path (client)),
+ DLT_STRING (", shutdown mode "),
+ DLT_UINT (shutdown_client_get_shutdown_mode (client)),
+ DLT_STRING (", timeout "),
+ DLT_UINT (shutdown_client_get_timeout (client)),
+ DLT_STRING (", request id "),
+ DLT_UINT (service->shutdown_queue->timeout_request));
/* it is, so we haven't receive da reply in time; drop the
* client from the queue and continue with the next right
const gchar *watchdog_str;
guint64 watchdog_usec = 0;
guint watchdog_sec = 0;
- gchar *message;
/* read the WATCHDOG_USEC environment variable and parse it
* into an unsigned integer */
application->watchdog_client = watchdog_client_new (watchdog_sec);
/* log information about the watchdog timeout using DLT */
- message = g_strdup_printf ("Updating systemd's watchdog timestamp every %d seconds",
- watchdog_sec);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Updating the systemd watchdog timestamp every "),
+ DLT_UINT (watchdog_sec), DLT_STRING (" seconds"));
}
/* install the signal handler */
gint node_state_id,
NSMLifecycleControlService *service)
{
- gchar *message;
- gint error_code;
+ gint error_code;
g_return_val_if_fail (IS_NSM_LIFECYCLE_CONTROL (object), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
if (node_state_id >= NSM_NODE_STATE_NOT_SET && node_state_id <= NSM_NODE_STATE_LAST)
{
/* log how we handled the node state */
- message = g_strdup_printf ("Applied the node state %i: %s",
- node_state_id, service->accept_state ? "yes": "no");
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Node state "), DLT_INT (node_state_id),
+ DLT_STRING (" applied: "),
+ DLT_STRING (service->accept_state ? "yes" : "no"));
/* alternate return value between successful(0) and fail(-1) with every handled call.
* We are temporarily assuming that 0 is success and -1 is failure */
else
{
/* log how we handled the node state */
- message = g_strdup_printf ("Received invalid node state %i", node_state_id);
- DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, DLT_STRING (message));
- g_free (message);
+ DLT_LOG (nsm_dummy_context, DLT_LOG_INFO,
+ DLT_STRING ("Received an invalid node state: "), DLT_INT (node_state_id));
/* let the caller know that it sent an invalid parameter */
error_code = NSM_ERROR_STATUS_PARAMETER;