diff --git a/dtool/src/dconfig/config_notify.cxx b/dtool/src/dconfig/config_notify.cxx index 9931a295a5..78d4bee5f0 100644 --- a/dtool/src/dconfig/config_notify.cxx +++ b/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; +} diff --git a/dtool/src/dconfig/config_notify.h b/dtool/src/dconfig/config_notify.h index d325c7834a..1dd6f562d0 100644 --- a/dtool/src/dconfig/config_notify.h +++ b/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__ */ diff --git a/dtool/src/dconfig/notify.cxx b/dtool/src/dconfig/notify.cxx index e704802c63..13d8f0fb9f 100644 --- a/dtool/src/dconfig/notify.cxx +++ b/dtool/src/dconfig/notify.cxx @@ -10,6 +10,7 @@ #include #include +#include // for strftime(). Notify *Notify::_global_ptr = (Notify *)NULL; diff --git a/dtool/src/dconfig/notifyCategory.cxx b/dtool/src/dconfig/notifyCategory.cxx index d5aa40dc92..97ffee343f 100644 --- a/dtool/src/dconfig/notifyCategory.cxx +++ b/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 {