[PATCH] Logs in milisec

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Logs in milisec

Vincent CHAVANIS
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/
[hidden email]
Tel : +33 4 93 97 71 64 (fax 68)