From: Ben Pfaff Date: Thu, 17 Jul 2008 00:50:06 +0000 (-0700) Subject: Log an error when the time is negative at vlog startup. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=792576de0140a4fc9050a2533b8761c0b997b547;p=openvswitch Log an error when the time is negative at vlog startup. --- diff --git a/include/vlog.h b/include/vlog.h index d4661629..068a6277 100644 --- a/include/vlog.h +++ b/include/vlog.h @@ -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 { diff --git a/lib/vlog.c b/lib/vlog.c index 8cd0c271..17be077a 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -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. */