[quagga-dev 4189] debug messages on terminal session do not include timestamps

Andrew J. Schorr aschorr at telemetry-investments.com
Thu Jun 29 17:28:42 BST 2006


I'm doing some debugging on a terminal session and trying to understand the
timing of various events, and I'm frustrated by the fact that the vty debug
messages do not include timestamps (whereas the messages logged to files
always include timestamps).  Is there any reason that lib/vty.c:vty_log_out
shouldn't be patched to include a timestamp?  Perhaps something
like the attached?

Regards,
Andy
-------------- next part --------------
Index: lib/vty.c
===================================================================
RCS file: /var/cvsroot/quagga/lib/vty.c,v
retrieving revision 1.52
diff -b -u -p -r1.52 vty.c
--- lib/vty.c	28 May 2006 08:18:38 -0000	1.52
+++ lib/vty.c	29 Jun 2006 16:27:14 -0000
@@ -154,12 +154,18 @@ vty_log_out (struct vty *vty, const char
   int ret;
   int len;
   char buf[1024];
+  struct tm *tm;
+
+  if ((tm = localtime(&recent_time.tv_sec)) != NULL)
+    len = strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S ", tm);
+  else
+    len = 0;
 
   if (level)
-    len = snprintf(buf, sizeof(buf), "%s: %s: ", level, proto_str);
+    ret = snprintf(buf+len, sizeof(buf)-len, "%s: %s: ", level, proto_str);
   else
-    len = snprintf(buf, sizeof(buf), "%s: ", proto_str);
-  if ((len < 0) || ((size_t)len >= sizeof(buf)))
+    ret = snprintf(buf+len, sizeof(buf)-len, "%s: ", proto_str);
+  if ((ret < 0) || ((size_t)(len += ret) >= sizeof(buf)))
     return -1;
 
   if (((ret = vsnprintf(buf+len, sizeof(buf)-len, format, va)) < 0) ||


More information about the Quagga-dev mailing list