From 792576de0140a4fc9050a2533b8761c0b997b547 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 16 Jul 2008 17:50:06 -0700 Subject: [PATCH] Log an error when the time is negative at vlog startup. --- include/vlog.h | 1 + lib/vlog.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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. */ -- 2.30.2