diff --git a/dtool/src/dconfig/notify.cxx b/dtool/src/dconfig/notify.cxx index 118956fbc9..ce40c7eab4 100644 --- a/dtool/src/dconfig/notify.cxx +++ b/dtool/src/dconfig/notify.cxx @@ -23,7 +23,6 @@ #include #include -#include // for strftime(). #ifdef WIN32 #include //for DebugBreak() diff --git a/dtool/src/dconfig/notifyCategory.cxx b/dtool/src/dconfig/notifyCategory.cxx index b1e37e357c..24b1cf199c 100644 --- a/dtool/src/dconfig/notifyCategory.cxx +++ b/dtool/src/dconfig/notifyCategory.cxx @@ -20,11 +20,14 @@ #include "notify.h" #include "config_notify.h" +#include // for strftime(). #include +time_t NotifyCategory::_server_delta = 0; + //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::Constructor -// Access: Public +// Access: Private // Description: //////////////////////////////////////////////////////////////////// NotifyCategory:: @@ -86,7 +89,7 @@ NotifyCategory(const string &fullname, const string &basename, //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::out -// Access: Public +// Access: Published // Description: Begins a new message to this Category at the // indicated severity level. If the indicated severity // level is enabled, this writes a prefixing string to @@ -100,7 +103,7 @@ out(NotifySeverity severity, bool prefix) const { if (prefix) { if (get_notify_timestamp()) { // Format a timestamp to include as a prefix as well. - time_t now = time(NULL); + time_t now = time(NULL) + _server_delta; struct tm *ptm = localtime(&now); char buffer[128]; @@ -123,7 +126,7 @@ out(NotifySeverity severity, bool prefix) const { //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::get_num_children -// Access: Public +// Access: Published // Description: Returns the number of child Categories of this // particular Category. //////////////////////////////////////////////////////////////////// @@ -134,7 +137,7 @@ get_num_children() const { //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::get_child -// Access: Public +// Access: Published // Description: Returns the nth child Category of this particular // Category. //////////////////////////////////////////////////////////////////// @@ -143,3 +146,16 @@ get_child(int i) const { assert(i >= 0 && i < (int)_children.size()); return _children[i]; } + +//////////////////////////////////////////////////////////////////// +// Function: NotifyCategory::set_server_delta +// Access: Published, Static +// Description: Sets a global delta (in seconds) between the local +// time and the server's time, for the purpose of +// synchronizing the time stamps in the log messages of +// the client with that of a known server. +//////////////////////////////////////////////////////////////////// +void NotifyCategory:: +set_server_delta(time_t delta) { + _server_delta = delta; +} diff --git a/dtool/src/dconfig/notifyCategory.h b/dtool/src/dconfig/notifyCategory.h index dbfc16485f..370f1ae343 100644 --- a/dtool/src/dconfig/notifyCategory.h +++ b/dtool/src/dconfig/notifyCategory.h @@ -76,6 +76,8 @@ PUBLISHED: int get_num_children() const; NotifyCategory *get_child(int i) const; + static void set_server_delta(time_t delta); + private: string _fullname; string _basename; @@ -84,6 +86,8 @@ private: typedef vector Children; Children _children; + static time_t _server_delta; + friend class Notify; };