28long NotifyCategory::_server_delta = 0;
34NotifyCategory(
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());
59out(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");
128 return _children.size();
136 assert(i < _children.size());
147 _server_delta = delta;
154std::string NotifyCategory::
155get_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;
171update_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;
190 _severity_cache = _severity;
194 mark_cache_valid(_local_modified);
203get_notify_timestamp() {
205 if (notify_timestamp ==
nullptr) {
207 (
"notify-timestamp",
false,
208 "Set true to output the date & time with each notify message.");
210 return *notify_timestamp;
219get_check_debug_notify_protect() {
221 if (check_debug_notify_protect ==
nullptr) {
223 (
"check-debug-notify-protect",
false,
224 "Set true to issue a warning message if a debug or spam "
225 "notify output is not protected within an if statement.");
227 return *check_debug_notify_protect;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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,...
This is a convenience class to specialize ConfigVariable as a boolean type.
This is a generic, untyped ConfigVariable.
const std::string & get_string_value() const
Returns the toplevel value of the variable, formatted as a string.
A particular category of error messages.
bool is_on(NotifySeverity severity) const
Returns true if messages of the indicated severity level ought to be reported for this Category.
get_child
Returns the nth child Category of this particular Category.
std::ostream & out(NotifySeverity severity, bool prefix=true) const
Begins a new message to this Category at the indicated severity level.
get_num_children
Returns the number of child Categories 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...
void config_initialized()
Intended to be called only by Config, this is a callback that indicates to Notify when Config has don...
static std::ostream & null()
A convenient way to get an ostream that doesn't do anything.
static Notify * ptr()
Returns the pointer to the global Notify object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.