diff options
author | ajs <ajs> | 2006-07-03 20:58:29 +0000 |
---|---|---|
committer | ajs <ajs> | 2006-07-03 20:58:29 +0000 |
commit | a19e4232871ed0411b100933dc26e64c879c5b2d (patch) | |
tree | bc4a7e882d3ec7ce24f630bfa3912258212acc24 /lib/vty.c | |
parent | 4d053e2fbb4e1af2d8907a61829cd9544015c91b (diff) | |
download | quagga-a19e4232871ed0411b100933dc26e64c879c5b2d.tar.bz2 quagga-a19e4232871ed0411b100933dc26e64c879c5b2d.tar.xz |
[debug] Debug messages to terminal vty sessions should include timestamps
2006-07-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* vty.c: (vty_log_out) Debug messages to terminal vty sessions
should include timestamps.
Diffstat (limited to 'lib/vty.c')
-rw-r--r-- | lib/vty.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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) || |