28 long NotifyCategory::_server_delta = 0;
34 NotifyCategory(
const std::string &fullname,
const std::string &basename,
39 _severity(get_config_name(), NS_unspecified,
40 "Default severity of this notify category",
42 _local_modified(initial_invalid_cache())
44 if (_parent !=
nullptr) {
45 _parent->_children.push_back(
this);
49 nassertv(_parent !=
nullptr || _fullname.empty());
59 out(NotifySeverity severity,
bool prefix)
const {
60 if (
is_on(severity)) {
67 if (severity == NS_info) {
68 return AndroidLogStream::out(severity) << *
this <<
": ";
70 return AndroidLogStream::out(severity) << *
this <<
"(" << severity <<
"): ";
73 return AndroidLogStream::out(severity);
78 if (get_notify_timestamp()) {
80 time_t now = time(
nullptr) + _server_delta;
83 localtime_s(&atm, &now);
85 localtime_r(&now, &atm);
89 strftime(buffer, 128,
":%m-%d-%Y %H:%M:%S ", &atm);
93 if (severity == NS_info) {
94 return nout << *
this <<
": ";
96 return nout << *
this <<
"(" << severity <<
"): ";
103 }
else if (severity <= NS_debug && get_check_debug_notify_protect()) {
108 nout <<
" **Not protected!** ";
110 nout << *
this <<
"(" << severity <<
"): ";
113 nassert_raise(
"unprotected debug statement");
126 size_t NotifyCategory::
127 get_num_children()
const {
128 return _children.size();
136 assert(i < _children.size());
147 _server_delta = delta;
154 std::string NotifyCategory::
155 get_config_name()
const {
156 std::string config_name;
158 if (_fullname.empty()) {
159 config_name =
"notify-level";
160 }
else if (!_basename.empty()) {
161 config_name =
"notify-level-" + _basename;
170 void NotifyCategory::
171 update_severity_cache() {
172 if (_severity == NS_unspecified) {
175 nout <<
"Invalid severity name for " << _severity.
get_name() <<
": " 178 if (_parent !=
nullptr) {
179 _severity_cache = _parent->get_severity();
183 _severity_cache = NS_info;
186 _severity_cache = _severity;
188 mark_cache_valid(_local_modified);
196 bool NotifyCategory::
197 get_notify_timestamp() {
199 if (notify_timestamp ==
nullptr) {
201 (
"notify-timestamp",
false,
202 "Set true to output the date & time with each notify message.");
204 return *notify_timestamp;
212 bool NotifyCategory::
213 get_check_debug_notify_protect() {
215 if (check_debug_notify_protect ==
nullptr) {
217 (
"check-debug-notify-protect",
false,
218 "Set true to issue a warning message if a debug or spam " 219 "notify output is not protected within an if statement.");
221 return *check_debug_notify_protect;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a convenience class to specialize ConfigVariable as a boolean type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A particular category of error messages.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static std::ostream & null()
A convenient way to get an ostream that doesn't do anything.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a generic, untyped ConfigVariable.
const std::string & get_string_value() const
Returns the toplevel value of the variable, formatted as a string.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_child
Returns the nth child Category of this particular Category.
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...
get_name
Returns the name of the variable.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & out(NotifySeverity severity, bool prefix=true) const
Begins a new message to this Category at the indicated severity level.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.