Re: [PATCH] Logs in milisec

"Vincent CHAVANIS" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <209b01c65a46$129fa220$9600a8c0@vince>
Hi,

What about this patch to CVS ?
No comments on it ?

regards

--
Telemaque - NICE - (FR)
Service Technique - Developpement
http://www.telemaque.fr/
[email protected]
Tel : +33 4 93 97 71 64 (fax 68)

----- Original Message ----- 
From: "Vincent CHAVANIS" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 29, 2006 11:41 PM
Subject: Re: [PATCH] Logs in milisec


here attached the v2 patch with all the logs with milisec
patch_milisec_log.txt (text/plain, 1.6 KB)
--- /gateway-cvs/gwlib/accesslog.c      2005-02-11 16:35:48.000000000 +0100
+++ /gateway/gwlib/accesslog.c  2006-04-03 14:28:35.000000000 +0200
@@ -174,9 +174,11 @@
 static void format(char *buf, const char *fmt)
 {
     time_t t;
+    struct timeval tv;
     struct tm tm;
     char *p, prefix[1024];
 
+    gettimeofday(&tv, 0);    
     p = prefix;
 
     if (markers) {
@@ -186,9 +188,9 @@
         else
             tm = gw_gmtime(t);
 
-        sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d ",
+        sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d.%03d ",
                 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-                tm.tm_hour, tm.tm_min, tm.tm_sec);
+                tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec/1000);
     } else {
         *p = '\0';
     }
diff -rau /gateway-cvs/gwlib/log.c /gateway/gwlib/log.c
--- /gateway-cvs/gwlib/log.c    2005-02-11 16:35:48.000000000 +0100
+++ /gateway/gwlib/log.c        2006-04-03 14:28:13.000000000 +0200
@@ -373,10 +373,12 @@
     };
     static int tab_size = sizeof(tab) / sizeof(tab[0]);
     time_t t;
+    struct timeval tv;
     struct tm tm;
     char *p, prefix[1024];
     long tid, pid;
     
+    gettimeofday(&tv, 0);
     p = prefix;
 
     if (with_timestamp) {
@@ -386,9 +388,9 @@
 #else
         tm = gw_gmtime(t);
 #endif
-        sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d ",
+        sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d.%03d ",
         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-        tm.tm_hour, tm.tm_min, tm.tm_sec);
+        tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec/1000);
     
         p = strchr(p, '\0');
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.