[gnome-builder] core: use g_get_real_time()



commit e45f9deea2ab90ebbd9da0c0cb5712d7fb67b1d8
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 6 17:24:54 2019 -0700

    core: use g_get_real_time()
    
    This also fixes the precision of the ten-thousandths precision.

 src/libide/core/ide-log.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/libide/core/ide-log.c b/src/libide/core/ide-log.c
index a1b0c2c5b..16dd3a3d3 100644
--- a/src/libide/core/ide-log.c
+++ b/src/libide/core/ide-log.c
@@ -201,7 +201,7 @@ ide_log_handler (const gchar    *log_domain,
                  const gchar    *message,
                  gpointer        user_data)
 {
-  struct timeval tv;
+  gint64 now;
   struct tm tt;
   time_t t;
   const gchar *level;
@@ -252,13 +252,13 @@ ide_log_handler (const gchar    *log_domain,
         }
 
       level = log_level_str_func (log_level);
-      gettimeofday (&tv, NULL);
-      t = (time_t) tv.tv_sec;
+      now = g_get_real_time ();
+      t = now / G_USEC_PER_SEC;
       tt = *localtime (&t);
       strftime (ftime, sizeof (ftime), "%H:%M:%S", &tt);
-      buffer = g_strdup_printf ("%s.%04ld  %40s[% 5d]: %s: %s\n",
+      buffer = g_strdup_printf ("%s.%04d  %40s[% 5d]: %s: %s\n",
                                 ftime,
-                                tv.tv_usec / 1000,
+                                (gint)((now % G_USEC_PER_SEC) / 100L),
                                 log_domain,
                                 ide_log_get_thread (),
                                 level,


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