Exclusively use DLT facilities to build log strings
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 1 Aug 2012 14:48:35 +0000 (15:48 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 1 Aug 2012 14:48:35 +0000 (15:48 +0100)
We used to build the log strings using g_strdup_printf() but this
results in a certain amount of overhead and extra code.

legacy-app-handler/main.c
node-startup-controller/la-handler-service.c
node-startup-controller/luc-starter.c
node-startup-controller/main.c
node-startup-controller/node-startup-controller-application.c
node-startup-controller/node-startup-controller-service.c
node-startup-controller/target-startup-monitor.c
nsm-dummy/nsm-consumer-service.c
nsm-dummy/nsm-dummy-application.c
nsm-dummy/nsm-lifecycle-control-service.c

index 5a156c0..d6080c6 100644 (file)
@@ -61,7 +61,6 @@ main (int    argc,
   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");
@@ -82,10 +81,9 @@ main (int    argc,
   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);
@@ -113,10 +111,10 @@ main (int    argc,
       || ((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);
@@ -146,11 +144,11 @@ main (int    argc,
                                        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);
@@ -165,9 +163,9 @@ main (int    argc,
   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);
index f2a9d93..51558c4 100644 (file)
@@ -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));
         }
     }
 }
index 25efec4..6a2d02e 100644 (file)
@@ -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;
     }
index 5b27e46..7667984 100644 (file)
@@ -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);
index e141599..929fe32 100644 (file)
@@ -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 */
index d984dce..6345bf1 100644 (file)
@@ -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);
index 555a0d1..635ee74 100644 (file)
@@ -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));
     }
 }
 
index b50beca..9d238f0 100644 (file)
@@ -242,7 +242,6 @@ nsm_consumer_service_handle_register_shutdown_client (NSMConsumer           *obj
   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);
@@ -278,13 +277,14 @@ nsm_consumer_service_handle_register_shutdown_client (NSMConsumer           *obj
       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
     {
@@ -296,10 +296,10 @@ nsm_consumer_service_handle_register_shutdown_client (NSMConsumer           *obj
       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 */
@@ -321,11 +321,12 @@ nsm_consumer_service_handle_register_shutdown_client (NSMConsumer           *obj
                                                  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);
@@ -353,7 +354,6 @@ nsm_consumer_service_handle_unregister_shutdown_client (NSMConsumer           *o
   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);
@@ -391,11 +391,10 @@ nsm_consumer_service_handle_unregister_shutdown_client (NSMConsumer           *o
       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,
@@ -427,16 +426,14 @@ nsm_consumer_service_handle_lifecycle_request_complete (NSMConsumer           *o
                                                         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);
@@ -466,23 +463,21 @@ nsm_consumer_service_handle_lifecycle_request_complete (NSMConsumer           *o
           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"));
         }
     }
 
@@ -496,7 +491,6 @@ nsm_consumer_service_shut_down_next_client_in_queue (NSMConsumerService *service
 {
   ShutdownConsumer *consumer;
   ShutdownClient   *client;
-  gchar            *message;
 
   g_return_if_fail (NSM_CONSUMER_IS_SERVICE (service));
   g_return_if_fail (service->shutdown_queue != NULL);
@@ -551,17 +545,18 @@ nsm_consumer_service_shut_down_next_client_in_queue (NSMConsumerService *service
   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);
@@ -576,11 +571,11 @@ nsm_consumer_service_shut_down_next_client_in_queue (NSMConsumerService *service
     }
   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 =
@@ -604,7 +599,6 @@ nsm_consumer_service_lifecycle_request_finish (GObject      *object,
   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));
@@ -618,11 +612,10 @@ nsm_consumer_service_lifecycle_request_finish (GObject      *object,
                                                         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 */
@@ -636,13 +629,14 @@ nsm_consumer_service_lifecycle_request_finish (GObject      *object,
   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 =
@@ -655,15 +649,16 @@ nsm_consumer_service_lifecycle_request_finish (GObject      *object,
   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 */
@@ -679,16 +674,18 @@ nsm_consumer_service_lifecycle_request_finish (GObject      *object,
   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 =
@@ -707,7 +704,6 @@ nsm_consumer_service_shut_down_client_timeout (gpointer user_data)
 {
   NSMConsumerService *service = NSM_CONSUMER_SERVICE (user_data);
   ShutdownClient     *client;
-  gchar              *message;
 
   g_return_val_if_fail (NSM_CONSUMER_IS_SERVICE (service), FALSE);
 
@@ -728,16 +724,18 @@ nsm_consumer_service_shut_down_client_timeout (gpointer user_data)
    * 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
index 38f6b94..fccc13c 100644 (file)
@@ -154,7 +154,6 @@ nsm_dummy_application_init (NSMDummyApplication *application)
   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 */
@@ -173,10 +172,9 @@ nsm_dummy_application_init (NSMDummyApplication *application)
       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 */
index 3186da5..9f918bf 100644 (file)
@@ -191,8 +191,7 @@ nsm_lifecycle_control_service_handle_set_node_state (NSMLifecycleControl
                                                      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);
@@ -202,10 +201,10 @@ nsm_lifecycle_control_service_handle_set_node_state (NSMLifecycleControl
   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 */
@@ -218,9 +217,8 @@ nsm_lifecycle_control_service_handle_set_node_state (NSMLifecycleControl
   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;