]> www.vanbest.org Git - sasc-ng.git/commitdiff
add microprecision timestamp to logging
authorleslie <unknown>
Thu, 21 May 2009 12:11:22 +0000 (20:11 +0800)
committerleslie <unknown>
Thu, 21 May 2009 12:11:22 +0000 (20:11 +0800)
log.c

diff --git a/log.c b/log.c
index 6176256b0f974a9b9f8a2cbe26fafa8af05dec95..1d99450be27d89697714c2f1b5ed3417dc92663d 100644 (file)
--- a/log.c
+++ b/log.c
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <time.h>
+#include <sys/time.h>
 
 #include <vdr/tools.h>
 #include <vdr/thread.h>
@@ -89,9 +90,11 @@ bool cLogging::GetHeader(int c, struct LogHeader *lh)
   const struct LogModule *lm=GetModule(c);
   if(lm) {
     if(!logcfg.noTimestamp) {
-      time_t tt=time(0);
+      struct timeval t;
+      gettimeofday(&t,NULL);
       struct tm tm_r;
-      strftime(lh->stamp,sizeof(lh->stamp),"%b %e %T",localtime_r(&tt,&tm_r));
+      int q=strftime(lh->stamp,sizeof(lh->stamp),"%b %e %T",localtime_r(&t.tv_sec,&tm_r));
+      snprintf(lh->stamp+q,sizeof(lh->stamp)-q,".%03u",(unsigned int)(t.tv_usec/1000));
       }
     else lh->stamp[0]=0;
     int i, o=LOPT(c)&~LMOD_ENABLE;