[gnome-control-center] log: Replace deprecated functions with modern equivalents



commit 92e1abf6f2b85a6c74267f82f8d8f041f3dddf84
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Sep 27 12:09:16 2019 +1200

    log: Replace deprecated functions with modern equivalents

 shell/cc-log.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/shell/cc-log.c b/shell/cc-log.c
index 5f6645cbe..95633bb97 100644
--- a/shell/cc-log.c
+++ b/shell/cc-log.c
@@ -54,11 +54,9 @@ log_handler (const gchar    *domain,
              const gchar    *message,
              gpointer        user_data)
 {
-  GTimeVal tv;
-  struct tm tt;
-  time_t t;
+  g_autoptr(GDateTime) now = NULL;
   const gchar *level;
-  gchar ftime[32];
+  g_autofree gchar *ftime = NULL;
   gchar *buffer;
 
   /* Skip ignored log domains */
@@ -66,13 +64,11 @@ log_handler (const gchar    *domain,
     return;
 
   level = log_level_str (log_level);
-  g_get_current_time (&tv);
-  t = (time_t) tv.tv_sec;
-  tt = *localtime (&t);
-  strftime (ftime, sizeof (ftime), "%H:%M:%S", &tt);
-  buffer = g_strdup_printf ("%s.%04ld  %24s: %s: %s\n",
+  now = g_date_time_new_now_local ();
+  ftime = g_date_time_format (now, "%H:%M:%S");
+  buffer = g_strdup_printf ("%s.%04d  %24s: %s: %s\n",
                             ftime,
-                            tv.tv_usec / 1000,
+                            g_date_time_get_microsecond (now) / 1000,
                             domain,
                             level,
                             message);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]