here attached the v2 patch with all the logs with milisec
--
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: Thursday, March 02, 2006 12:59 PM
Subject: [PATCH] Logs in milisec
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 /gateway/gwlib/accesslog.c /gateway2/gwlib/accesslog.c
--- /gateway/gwlib/accesslog.c 2005-02-11 16:35:48.000000000 +0100
+++ /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';
}
diff -ru /gateway/gwlib/log.c /gateway2/gwlib/log.c
--- /gateway/gwlib/log.c 2005-02-11 16:35:48.000000000 +0100
+++ /gateway2/gwlib/log.c 2006-03-29 23:29:45.000000000 +0200
@@ -373,9 +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;
@@ -386,9 +389,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');
}
--
Telemaque - NICE - (FR)
Service Technique - Developpement
http://www.telemaque.fr/
[EMAIL PROTECTED]
Tel : +33 4 93 97 71 64 (fax 68)
diff -ru /gateway/gwlib/accesslog.c /gateway2/gwlib/accesslog.c
--- /gateway/gwlib/accesslog.c 2005-02-11 16:35:48.000000000 +0100
+++ /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';
}
diff -ru /gateway/gwlib/log.c /gateway2/gwlib/log.c
--- /gateway/gwlib/log.c 2005-02-11 16:35:48.000000000 +0100
+++ /gateway2/gwlib/log.c 2006-03-29 23:29:45.000000000 +0200
@@ -373,9 +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;
@@ -386,9 +389,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');
}