extensions to notify

This commit is contained in:
David Rose 2003-02-04 22:33:04 +00:00
parent 32b0611dab
commit f5e5fcf8e2
3 changed files with 25 additions and 6 deletions

View File

@ -23,7 +23,6 @@
#include <filename.h>
#include <ctype.h>
#include <time.h> // for strftime().
#ifdef WIN32
#include <windows.h> //for DebugBreak()

View File

@ -20,11 +20,14 @@
#include "notify.h"
#include "config_notify.h"
#include <time.h> // for strftime().
#include <assert.h>
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;
}

View File

@ -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<NotifyCategory *> Children;
Children _children;
static time_t _server_delta;
friend class Notify;
};