prevent crash due to overly early warning message

This commit is contained in:
David Rose 2004-12-14 06:00:02 +00:00
parent 948278ee43
commit e9f8618c5d
2 changed files with 22 additions and 5 deletions

View File

@ -27,10 +27,6 @@
time_t NotifyCategory::_server_delta = 0;
static ConfigVariableBool notify_timestamp
("notify-timestamp", false,
"Set true to output the date & time with each notify message.");
////////////////////////////////////////////////////////////////////
// Function: NotifyCategory::Constructor
// Access: Private
@ -93,7 +89,7 @@ ostream &NotifyCategory::
out(NotifySeverity severity, bool prefix) const {
if (is_on(severity)) {
if (prefix) {
if (notify_timestamp) {
if (get_notify_timestamp()) {
// Format a timestamp to include as a prefix as well.
time_t now = time(NULL) + _server_delta;
struct tm *ptm = localtime(&now);
@ -170,3 +166,23 @@ get_config_name() const {
return config_name;
}
////////////////////////////////////////////////////////////////////
// Function: NotifyCategory::get_notify_timestamp
// Access: Private, Static
// Description: Returns the value of the notify-timestamp
// ConfigVariable. This is defined using a method
// accessor rather than a static ConfigVariableBool, to
// protect against the variable needing to be accessed
// at static init time.
////////////////////////////////////////////////////////////////////
bool NotifyCategory::
get_notify_timestamp() {
static ConfigVariableBool *notify_timestamp = NULL;
if (notify_timestamp == (ConfigVariableBool *)NULL) {
notify_timestamp = new ConfigVariableBool
("notify-timestamp", false,
"Set true to output the date & time with each notify message.");
}
return *notify_timestamp;
}

View File

@ -80,6 +80,7 @@ PUBLISHED:
private:
string get_config_name() const;
static bool get_notify_timestamp();
string _fullname;
string _basename;