summaryrefslogtreecommitdiff
path: root/node-startup-controller
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-08-01 15:48:35 +0100
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-08-01 15:48:35 +0100
commitdfedc09b1ebd7b66ad0198419802e4ce27fcef4f (patch)
treec0e818e5ad32a73d6b15f44dd288ee57d001c797 /node-startup-controller
parenteb072892102c2a819dd3ea5bb0f6e81e2b96a9a0 (diff)
downloadnode-startup-controller-dfedc09b1ebd7b66ad0198419802e4ce27fcef4f.tar.gz
Exclusively use DLT facilities to build log strings
We used to build the log strings using g_strdup_printf() but this results in a certain amount of overhead and extra code.
Diffstat (limited to 'node-startup-controller')
-rw-r--r--node-startup-controller/la-handler-service.c84
-rw-r--r--node-startup-controller/luc-starter.c31
-rw-r--r--node-startup-controller/main.c35
-rw-r--r--node-startup-controller/node-startup-controller-application.c62
-rw-r--r--node-startup-controller/node-startup-controller-service.c27
-rw-r--r--node-startup-controller/target-startup-monitor.c53
6 files changed, 121 insertions, 171 deletions
diff --git a/node-startup-controller/la-handler-service.c b/node-startup-controller/la-handler-service.c
index f2a9d93..51558c4 100644
--- a/node-startup-controller/la-handler-service.c
+++ b/node-startup-controller/la-handler-service.c
@@ -158,7 +158,6 @@ la_handler_service_constructed (GObject *object)
{
LAHandlerService *service = LA_HANDLER_SERVICE (object);
GError *error = NULL;
- gchar *log_text;
/* connect to the node state manager */
service->nsm_consumer =
@@ -168,10 +167,9 @@ la_handler_service_constructed (GObject *object)
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);
}
}
@@ -302,7 +300,6 @@ la_handler_service_handle_register (LAHandler *interface,
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);
@@ -363,10 +360,9 @@ la_handler_service_handle_register (LAHandler *interface,
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);
}
@@ -404,7 +400,6 @@ la_handler_service_handle_register_finish (GObject *object,
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));
@@ -416,10 +411,9 @@ la_handler_service_handle_register_finish (GObject *object,
&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);
}
@@ -488,7 +482,6 @@ la_handler_service_handle_consumer_lifecycle_request_finish (JobManager *manage
{
LAHandlerServiceData *data = (LAHandlerServiceData *)user_data;
GError *err = NULL;
- gchar *log_text;
gint error_status = NSM_ERROR_STATUS_OK;
gint status = NSM_ERROR_STATUS_OK;
@@ -498,18 +491,16 @@ la_handler_service_handle_consumer_lifecycle_request_finish (JobManager *manage
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;
@@ -530,28 +521,24 @@ la_handler_service_handle_consumer_lifecycle_request_finish (JobManager *manage
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);
@@ -642,7 +629,6 @@ la_handler_service_deregister_consumers (LAHandlerService *service)
const gchar *object_path;
const gchar *unit;
GError *error = NULL;
- gchar *log_text;
gint error_code;
gint shutdown_mode;
@@ -664,20 +650,18 @@ la_handler_service_deregister_consumers (LAHandlerService *service)
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));
}
}
}
diff --git a/node-startup-controller/luc-starter.c b/node-startup-controller/luc-starter.c
index 25efec4..6a2d02e 100644
--- a/node-startup-controller/luc-starter.c
+++ b/node-startup-controller/luc-starter.c
@@ -176,7 +176,6 @@ luc_starter_constructed (GObject *object)
LUCStarter *starter = LUC_STARTER (object);
GError *error = NULL;
gchar **types;
- gchar *log_text;
guint n;
gint type;
@@ -189,10 +188,9 @@ luc_starter_constructed (GObject *object)
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);
}
@@ -390,7 +388,6 @@ luc_starter_start_app_finish (JobManager *manager,
LUCStarter *starter = LUC_STARTER (user_data);
GPtrArray *apps;
gboolean app_found = FALSE;
- gchar *message;
guint n;
gint group;
@@ -405,10 +402,9 @@ luc_starter_start_app_finish (JobManager *manager,
/* 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 */
@@ -483,7 +479,6 @@ luc_starter_check_luc_required_finish (GObject *object,
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));
@@ -493,10 +488,9 @@ luc_starter_check_luc_required_finish (GObject *object,
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,
@@ -542,7 +536,6 @@ luc_starter_start_groups_for_real (LUCStarter *starter)
GList *groups;
GList *lp;
gchar **apps;
- gchar *log_text;
guint n;
gint group;
gint type;
@@ -572,9 +565,9 @@ luc_starter_start_groups_for_real (LUCStarter *starter)
&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;
}
diff --git a/node-startup-controller/main.c b/node-startup-controller/main.c
index 5b27e46..7667984 100644
--- a/node-startup-controller/main.c
+++ b/node-startup-controller/main.c
@@ -57,7 +57,6 @@ main (int argc,
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");
@@ -78,9 +77,9 @@ main (int argc,
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);
@@ -97,10 +96,9 @@ main (int argc,
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);
@@ -112,10 +110,9 @@ main (int argc,
/* 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);
@@ -130,10 +127,9 @@ main (int argc,
/* 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);
@@ -153,10 +149,9 @@ main (int argc,
/* 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);
diff --git a/node-startup-controller/node-startup-controller-application.c b/node-startup-controller/node-startup-controller-application.c
index e141599..929fe32 100644
--- a/node-startup-controller/node-startup-controller-application.c
+++ b/node-startup-controller/node-startup-controller-application.c
@@ -204,7 +204,6 @@ node_startup_controller_application_init (NodeStartupControllerApplication *appl
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 */
@@ -223,10 +222,9 @@ node_startup_controller_application_init (NodeStartupControllerApplication *appl
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"));
}
}
@@ -286,7 +284,6 @@ node_startup_controller_application_constructed (GObject *object)
NSMConsumer *nsm_consumer;
GError *error = NULL;
gchar *bus_name = "org.genivi.NodeStartupController1";
- gchar *log_text;
gchar *object_path;
gint timeout;
@@ -326,10 +323,9 @@ node_startup_controller_application_constructed (GObject *object)
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);
}
@@ -353,7 +349,6 @@ node_startup_controller_application_handle_register_finish (GObject *object
{
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));
@@ -363,25 +358,23 @@ node_startup_controller_application_handle_register_finish (GObject *object
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));
}
}
@@ -395,7 +388,6 @@ node_startup_controller_application_handle_unregister_finish (GObject *obje
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));
@@ -406,25 +398,23 @@ node_startup_controller_application_handle_unregister_finish (GObject *obje
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 */
diff --git a/node-startup-controller/node-startup-controller-service.c b/node-startup-controller/node-startup-controller-service.c
index d984dce..6345bf1 100644
--- a/node-startup-controller/node-startup-controller-service.c
+++ b/node-startup-controller/node-startup-controller-service.c
@@ -230,7 +230,6 @@ node_startup_controller_service_handle_finish_luc_registration (NodeStartupContr
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);
@@ -239,10 +238,9 @@ node_startup_controller_service_handle_finish_luc_registration (NodeStartupContr
/* 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);
@@ -253,9 +251,9 @@ node_startup_controller_service_handle_finish_luc_registration (NodeStartupContr
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);
}
@@ -292,7 +290,6 @@ node_startup_controller_service_handle_register_with_luc (NodeStartupController
GList *luc_types;
gchar *app;
gchar *debug_text = NULL;
- gchar *log_text = NULL;
guint n;
gint luc_type;
@@ -303,10 +300,9 @@ node_startup_controller_service_handle_register_with_luc (NodeStartupController
/* 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);
@@ -411,10 +407,9 @@ node_startup_controller_service_handle_register_with_luc (NodeStartupController
/* 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);
diff --git a/node-startup-controller/target-startup-monitor.c b/node-startup-controller/target-startup-monitor.c
index 555a0d1..635ee74 100644
--- a/node-startup-controller/target-startup-monitor.c
+++ b/node-startup-controller/target-startup-monitor.c
@@ -131,8 +131,7 @@ target_startup_monitor_class_init (TargetStartupMonitorClass *klass)
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 =
@@ -143,10 +142,9 @@ target_startup_monitor_init (TargetStartupMonitor *monitor)
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);
}
@@ -289,7 +287,6 @@ target_startup_monitor_get_unit_finish (GObject *object,
{
GetUnitData *data = user_data;
GError *error = NULL;
- gchar *message;
gchar *object_path;
g_return_if_fail (IS_SYSTEMD_MANAGER (object));
@@ -301,10 +298,9 @@ target_startup_monitor_get_unit_finish (GObject *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 */
@@ -314,9 +310,9 @@ target_startup_monitor_get_unit_finish (GObject *object,
}
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;
@@ -344,7 +340,6 @@ target_startup_monitor_unit_proxy_new_finish (GObject *object,
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);
@@ -354,9 +349,10 @@ target_startup_monitor_unit_proxy_new_finish (GObject *object,
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
@@ -365,10 +361,9 @@ target_startup_monitor_unit_proxy_new_finish (GObject *object,
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)
@@ -418,7 +413,6 @@ target_startup_monitor_set_node_state_finish (GObject *object,
{
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));
@@ -429,17 +423,16 @@ target_startup_monitor_set_node_state_finish (GObject *object,
(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));
}
}