15 #include "notifyCategory.h" 17 #include "configPageManager.h" 18 #include "configVariableString.h" 19 #include "configVariableBool.h" 20 #include "config_prc.h" 23 #include "androidLogStream.h" 29 long NotifyCategory::_server_delta = 0;
37 NotifyCategory(
const string &fullname,
const string &basename,
42 _severity(get_config_name(), NS_unspecified,
43 "Default severity of this notify category",
45 _local_modified(initial_invalid_cache())
48 _parent->_children.push_back(
this);
66 out(NotifySeverity severity,
bool prefix)
const {
67 if (
is_on(severity)) {
74 return AndroidLogStream::out(severity) << *
this <<
": ";
76 return AndroidLogStream::out(severity);
81 if (get_notify_timestamp()) {
83 time_t now = time(NULL) + _server_delta;
84 struct tm *ptm = localtime(&now);
87 strftime(buffer, 128,
":%m-%d-%Y %H:%M:%S ", ptm);
91 if (severity == NS_info) {
92 return nout << *
this <<
": ";
94 return nout << *
this <<
"(" << severity <<
"): ";
101 }
else if (severity <= NS_debug && get_check_debug_notify_protect()) {
107 nout <<
" **Not protected!** ";
109 nout << *
this <<
"(" << severity <<
"): ";
112 nassertr(
false, nout);
130 return _children.size();
141 assert(i >= 0 && i < (
int)_children.size());
155 _server_delta = delta;
164 string NotifyCategory::
165 get_config_name()
const {
168 if (_fullname.empty()) {
169 config_name =
"notify-level";
170 }
else if (!_basename.empty()) {
171 config_name =
"notify-level-" + _basename;
182 void NotifyCategory::
183 update_severity_cache() {
184 if (_severity == NS_unspecified) {
188 nout <<
"Invalid severity name for " << _severity.
get_name() <<
": " 192 _severity_cache = _parent->get_severity();
196 _severity_cache = NS_info;
199 _severity_cache = _severity;
201 mark_cache_valid(_local_modified);
213 bool NotifyCategory::
214 get_notify_timestamp() {
218 (
"notify-timestamp",
false,
219 "Set true to output the date & time with each notify message.");
221 return *notify_timestamp;
233 bool NotifyCategory::
234 get_check_debug_notify_protect() {
238 (
"check-debug-notify-protect",
false,
239 "Set true to issue a warning message if a debug or spam " 240 "notify output is not protected within an if statement.");
242 return *check_debug_notify_protect;
This is a convenience class to specialize ConfigVariable as a boolean type.
const string & get_name() const
Returns the name of the variable.
int get_num_children() const
Returns the number of child Categories of this particular Category.
A particular category of error messages.
static ostream & null()
A convenient way to get an ostream that doesn't do anything.
This is a generic, untyped ConfigVariable.
static void set_server_delta(long delta)
Sets a global delta (in seconds) between the local time and the server's time, for the purpose of syn...
NotifyCategory * get_child(int i) const
Returns the nth child Category of this particular Category.
bool has_value() const
Returns true if this variable has an explicit value, either from a prc file or locally set...
bool is_on(NotifySeverity severity) const
Returns true if messages of the indicated severity level ought to be reported for this Category...
const string & get_string_value() const
Returns the toplevel value of the variable, formatted as a string.
ostream & out(NotifySeverity severity, bool prefix=true) const
Begins a new message to this Category at the indicated severity level.