Log an error when the time is negative at vlog startup.
authorBen Pfaff <blp@nicira.com>
Thu, 17 Jul 2008 00:50:06 +0000 (17:50 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 18 Jul 2008 20:24:16 +0000 (13:24 -0700)
include/vlog.h
lib/vlog.c

index d466162..068a627 100644 (file)
@@ -83,6 +83,7 @@ enum vlog_facility vlog_get_facility_val(const char *name);
         VLOG_MODULE(vconn_tcp)                  \
         VLOG_MODULE(vconn_ssl)                  \
         VLOG_MODULE(vconn)                      \
+        VLOG_MODULE(vlog)                       \
 
 /* VLM_ constant for each vlog module. */
 enum vlog_module {
index 8cd0c27..17be077 100644 (file)
@@ -44,6 +44,8 @@
 #include "dynamic-string.h"
 #include "util.h"
 
+#define THIS_MODULE VLM_vlog
+
 /* Name for each logging level. */
 static const char *level_names[VLL_N_LEVELS] = {
     [VLL_EMER] = "EMER",
@@ -251,8 +253,18 @@ vlog_set_verbosity(const char *arg)
 void
 vlog_init(void) 
 {
+    time_t now;
     openlog(program_name, LOG_NDELAY, LOG_DAEMON);
     vlog_set_levels(VLM_ANY_MODULE, VLF_CONSOLE, VLL_WARN);
+    now = time(0);
+    if (now < 0) {
+        struct tm tm;
+        char s[128];
+
+        localtime_r(&now, &tm);
+        strftime(s, sizeof s, "%a, %d %b %Y %H:%M:%S %z", &tm);
+        VLOG_ERR("current time is negative: %s (%ld)", s, (long int) now);
+    }
 }
 
 /* Closes the logging subsystem. */