[Xfce4-commits] [apps/xfce4-screensaver] 01/17: add microseconds to gs_debug() output

noreply at xfce.org noreply at xfce.org
Sat Mar 9 22:23:36 CET 2019


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screensaver.

commit 9ec9e8cb594e4ff7da05f2b21e14b5e6467b198f
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Tue Feb 5 21:14:04 2019 -0400

    add microseconds to gs_debug() output
---
 src/gs-debug.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/gs-debug.c b/src/gs-debug.c
index 7cbd25a..a2d691c 100644
--- a/src/gs-debug.c
+++ b/src/gs-debug.c
@@ -22,11 +22,13 @@
 
 #include <config.h>
 
+#include <sys/time.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
+#include <math.h>
 #include <unistd.h>
 
 #include <glib.h>
@@ -48,8 +50,11 @@ gs_debug_real (const char *func,
                const char *format, ...) {
     va_list args;
     char    buffer[1025];
-    char   *str_time;
-    time_t  the_time;
+    char    *str_time;
+    int     millisec;
+    struct  tm* tm_info;
+    struct  timeval tv;
+
 
     if (debugging == FALSE)
         return;
@@ -60,13 +65,20 @@ gs_debug_real (const char *func,
 
     va_end (args);
 
-    time (&the_time);
+    gettimeofday(&tv, NULL);
+    millisec = lrint(tv.tv_usec/1000.0);
+    if (millisec>=1000) {
+        millisec -=1000;
+        tv.tv_sec++;
+    }
+
+    tm_info = localtime(&tv.tv_sec);
     str_time = g_new0 (char, 255);
-    strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
+    strftime (str_time, 254, "%H:%M:%S", tm_info);
 
     fprintf ((debug_out ? debug_out : stderr),
-             "[%s] %s:%d (%s):\t %s\n",
-             func, file, line, str_time, buffer);
+             "[%s] %s:%d (%s.%03d):\t %s\n",
+             func, file, line, str_time, millisec, buffer);
 
     if (debug_out)
         fflush (debug_out);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list