[PATCH] Logs in milisec

"Vincent CHAVANIS" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <115301c63de8$5cd49320$9600a8c0@vince>
Hi,

For those who are interrested in having their logs with milisec
It's particularily interresting when you need to tune your gateway 
when your operator checks for a QOS.

regards

Vincent


diff -ru /cvsroot/gateway/gwlib/accesslog.c /cvsroot/gateway2/gwlib/accesslog.c
--- /cvsroot/gateway/gwlib/accesslog.c       2005-02-11 16:35:48.000000000 +0100
+++ /cvsroot/gateway2/gwlib/accesslog.c      2006-03-02 11:51:47.000000000 +0100
@@ -174,9 +174,12 @@
 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 +189,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';
     }



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