Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
7389f48672

+ 10 - 0
dtool/src/dconfig/config_notify.cxx

@@ -22,3 +22,13 @@ get_assert_abort() {
   }
   return *assert_abort;
 }
+
+bool
+get_notify_timestamp() {
+  static bool *notify_timestamp = (bool *)NULL;
+  if (notify_timestamp == (bool *)NULL) {
+    notify_timestamp = new bool;
+    *notify_timestamp = config_notify.GetBool("notify-timestamp", false);
+  }
+  return *notify_timestamp;
+}

+ 1 - 0
dtool/src/dconfig/config_notify.h

@@ -12,5 +12,6 @@
 ConfigureDecl(config_notify, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG);
 
 bool get_assert_abort();
+bool get_notify_timestamp();
 
 #endif /* __CONFIG_NOTIFY_H__ */

+ 1 - 0
dtool/src/dconfig/notify.cxx

@@ -10,6 +10,7 @@
 #include <filename.h>
 
 #include <ctype.h>
+#include <time.h>  // for strftime().
 
 Notify *Notify::_global_ptr = (Notify *)NULL;
 

+ 10 - 0
dtool/src/dconfig/notifyCategory.cxx

@@ -85,6 +85,16 @@ ostream &NotifyCategory::
 out(NotifySeverity severity, bool prefix) const {
   if (is_on(severity)) {
     if (prefix) {
+      if (get_notify_timestamp()) {
+	// Format a timestamp to include as a prefix as well.
+	time_t now = time(NULL);
+	struct tm *ptm = localtime(&now);
+	
+	char buffer[128];
+	strftime(buffer, 128, ":%m-%d-%Y %H:%M:%S ", ptm);
+	nout << buffer;
+      }
+
       if (severity == NS_info) {
 	return nout << *this << ": ";
       } else {