]> code.citadel.org Git - citadel.git/commitdiff
* sysdep.c: lprintf() now generates timestamps
authorMichael Hampton <io_error@uncensored.citadel.org>
Sun, 28 Jan 2001 09:50:02 +0000 (09:50 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Sun, 28 Jan 2001 09:50:02 +0000 (09:50 +0000)
citadel/ChangeLog
citadel/sysdep.c

index 9c02de18515442bb943954cba5b86ba835d55f8a..d53575a0c134b9f6c7edfda124bbb2ea8da22ab2 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.75  2001/01/28 09:50:02  error
+ * sysdep.c: lprintf() now generates timestamps
+
  Revision 573.74  2001/01/28 07:35:04  error
   * serv_bio.c: RBIO now also returns stats about a user, see session.txt
 
@@ -2344,4 +2347,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index 74a71d63b9c3507987d0fe90c8097076e565cfd6..3ece6e7be85f90261fde149f42f3f05a47b6c67b 100644 (file)
@@ -95,7 +95,20 @@ void lprintf(int loglevel, const char *format, ...) {
         va_end(arg_ptr);   
 
        if (loglevel <= verbosity) { 
-               fprintf(stderr, "%s", buf);
+               struct timeval tv;
+               struct tm *tim;
+
+               gettimeofday(&tv, NULL);
+               tim = localtime(&(tv.tv_sec));
+               /*
+                * Log provides millisecond accuracy.  If you need
+                * microsecond accuracy and your OS supports it, change
+                * %03ld to %06ld and remove " / 1000" after tv.tv_usec.
+                */
+               fprintf(stderr, "%04d/%02d/%02d %2d:%02d:%02d.%03ld %s",
+                       tim->tm_year + 1900, tim->tm_mon + 1, tim->tm_mday,
+                       tim->tm_hour, tim->tm_min, tim->tm_sec,
+                       tv.tv_usec / 1000, buf);
                fflush(stderr);
        }