]> git.puffer.fish Git - mirror/frr.git/commitdiff
[debug] Debug messages to terminal vty sessions should include timestamps
authorAndrew J. Schorr <ajschorr@alumni.princeton.edu>
Mon, 3 Jul 2006 20:58:29 +0000 (20:58 +0000)
committerAndrew J. Schorr <ajschorr@alumni.princeton.edu>
Mon, 3 Jul 2006 20:58:29 +0000 (20:58 +0000)
2006-07-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

* vty.c: (vty_log_out) Debug messages to terminal vty sessions
  should include timestamps.

lib/ChangeLog
lib/vty.c

index b52370f7ac215a11ab8c7460f50c6e7455a7131b..e95e2a3a0d60246462d40f7be636321161ae1f86 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+       * vty.c: (vty_log_out) Debug messages to terminal vty sessions
+         should include timestamps.
+
 2006-06-28 Paul Jakma <paul.jakma@sun.com>
 
        * memory.c: Fix typo in cpp conditional around malloc.h, from
index b037c70cc540879bf03de03b428c50334423e0d9..8de32870951ef439ff433baa78a38feab70095f9 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -154,12 +154,18 @@ vty_log_out (struct vty *vty, const char *level, const char *proto_str,
   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) ||