First of all,
I wish you a Happy new year to the list,

Then as many people asked about this feature
Introducing --enable-millisec-log that will enable logging in millisecond.
by default, this is disabled.

Any comments ?

Vincent.


----- Original Message ----- From: "Stipe Tolj" <[EMAIL PROTECTED]>
To: "Vincent CHAVANIS" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Thursday, November 29, 2007 10:50 PM
Subject: Re: Include miliseconds in logging


Vincent CHAVANIS schrieb:
I thought about a macro :-)

a pre-processdor macro is resolved at compile time, so this is same as at
configure time ;)

a macro is not "dynamic" while runtime.

Stipe

-------------------------------------------------------------------
Kölner Landstrasse 419
40589 Düsseldorf, NRW, Germany

tolj.org system architecture      Kannel Software Foundation (KSF)
http://www.tolj.org/              http://www.kannel.org/

mailto:st_{at}_tolj.org           mailto:stolj_{at}_kannel.org
-------------------------------------------------------------------

diff -rauw /gateway-cvs/configure /gateway/configure
--- /gateway-cvs/configure      2007-04-04 02:39:45.000000000 +0200
+++ /gateway/configure  2008-01-09 11:03:54.000000000 +0100
@@ -854,6 +854,7 @@
  --enable-pam           enable pam authentication disabled
  --enable-debug         enable non-reentrant debugging for wmls compiler 
disabled
  --enable-localtime     log file time stamps in local time, not GMT enabled
+  --enable-millisec-log   log file time stamps in milliseconds
  --enable-mutex-stats    produce information about lock contention
  --disable-cookies       disable cookie support for WSP enabled
  --disable-keepalive     disable HTTP/1.1 keep-alive support enabled
@@ -10051,6 +10052,19 @@
fi;


+# Check whether --enable-millisec-log was given.
+if test "${enable_millisec_log+set}" = set; then
+  enableval="$enable_millisec_log"
+
+  if test "$enableval" = yes; then
+     echo enabling milliseconds in our logs
+     cat >>confdefs.h <<\_ACEOF
+#define LOG_MILLISEC 1
+_ACEOF
+  fi
+fi;
+
+

# Check whether --enable-mutex-stats or --disable-mutex-stats was given.
if test "${enable_mutex_stats+set}" = set; then
Seulement dans /gateway: configure64.sh
diff -rauw /gateway-cvs/configure.in /gateway/configure.in
--- /gateway-cvs/configure.in   2007-04-04 02:39:44.000000000 +0200
+++ /gateway/configure.in       2008-01-09 11:23:58.000000000 +0100
@@ -698,6 +698,14 @@
  AC_DEFINE(LOG_TIMESTAMP_LOCALTIME)
])

+dnl Implement --enable-millisec-log option.
+
+AC_ARG_ENABLE(log_millisec,
+[  --enable-millisec-log    log file time stamps in milliseconds], [
+  if test "$enableval" = yes; then
+ AC_DEFINE(LOG_MILLISEC) + fi +])
dnl --enable-mutex-stats option.


--- /gateway-cvs/gwlib/log.c    2007-01-26 17:18:33.000000000 +0100
+++ /gateway/gwlib/log.c        2008-01-09 10:51:29.000000000 +0100
@@ -370,6 +370,11 @@
    char *p, prefix[1024];
    long tid, pid;
+#if LOG_MILLISEC
+    struct timeval tv;
+    gettimeofday(&tv, 0);
+#endif
+
    p = prefix;

    if (with_timestamp) {
@@ -379,10 +384,16 @@
#else
        tm = gw_gmtime(t);
#endif
+
+#if LOG_MILLISEC
+        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, tv.tv_usec/1000);
+#else
        sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d ",
        tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
        tm.tm_hour, tm.tm_min, tm.tm_sec);
- +#endif p = strchr(p, '\0');
    }


diff -rauw /gateway-cvs/gwlib/accesslog.c /gateway/gwlib/accesslog.c
--- /gateway-cvs/gwlib/accesslog.c      2007-01-08 00:52:57.000000000 +0100
+++ /gateway/gwlib/accesslog.c  2008-01-09 10:51:54.000000000 +0100
@@ -177,6 +177,11 @@
    struct tm tm;
    char *p, prefix[1024];

+#if LOG_MILLISEC
+    struct timeval tv;
+ gettimeofday(&tv, 0); +#endif
+
    p = prefix;

    if (markers) {
@@ -186,9 +191,16 @@
        else
            tm = gw_gmtime(t);

+#if LOG_MILLISEC
+        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, tv.tv_usec/1000);
+#else sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d ",
                tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
                tm.tm_hour, tm.tm_min, tm.tm_sec);
+#endif
+
    } else {
        *p = '\0';
    }

Reply via email to