mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-29 23:35:30 +01:00
Added a new important log level to PLogger.
This commit is contained in:
parent
e53f2b27ba
commit
642db98328
@ -56,6 +56,10 @@ void _PLogger::log_error(const String &str) {
|
|||||||
PLogger::log_error(str);
|
PLogger::log_error(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _PLogger::log_important(const String &str) {
|
||||||
|
PLogger::log_important(str);
|
||||||
|
}
|
||||||
|
|
||||||
_PLogger::LogLevel _PLogger::get_log_level() {
|
_PLogger::LogLevel _PLogger::get_log_level() {
|
||||||
return static_cast<LogLevel>(static_cast<int>(PLogger::get_log_level()));
|
return static_cast<LogLevel>(static_cast<int>(PLogger::get_log_level()));
|
||||||
}
|
}
|
||||||
@ -83,6 +87,7 @@ void _PLogger::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("log_message", "str"), &_PLogger::log_message);
|
ClassDB::bind_method(D_METHOD("log_message", "str"), &_PLogger::log_message);
|
||||||
ClassDB::bind_method(D_METHOD("log_warning", "str"), &_PLogger::log_warning);
|
ClassDB::bind_method(D_METHOD("log_warning", "str"), &_PLogger::log_warning);
|
||||||
ClassDB::bind_method(D_METHOD("log_error", "str"), &_PLogger::log_error);
|
ClassDB::bind_method(D_METHOD("log_error", "str"), &_PLogger::log_error);
|
||||||
|
ClassDB::bind_method(D_METHOD("log_important", "str"), &_PLogger::log_important);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_log_level"), &_PLogger::get_log_level);
|
ClassDB::bind_method(D_METHOD("get_log_level"), &_PLogger::get_log_level);
|
||||||
ClassDB::bind_method(D_METHOD("set_log_level", "log_level"), &_PLogger::set_log_level);
|
ClassDB::bind_method(D_METHOD("set_log_level", "log_level"), &_PLogger::set_log_level);
|
||||||
@ -92,6 +97,7 @@ void _PLogger::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(LOG_LEVEL_MESSAGE);
|
BIND_ENUM_CONSTANT(LOG_LEVEL_MESSAGE);
|
||||||
BIND_ENUM_CONSTANT(LOG_LEVEL_WARNING);
|
BIND_ENUM_CONSTANT(LOG_LEVEL_WARNING);
|
||||||
BIND_ENUM_CONSTANT(LOG_LEVEL_ERROR);
|
BIND_ENUM_CONSTANT(LOG_LEVEL_ERROR);
|
||||||
|
BIND_ENUM_CONSTANT(LOG_LEVEL_IMPORTANT);
|
||||||
BIND_ENUM_CONSTANT(LOG_LEVEL_NONE);
|
BIND_ENUM_CONSTANT(LOG_LEVEL_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
LOG_LEVEL_MESSAGE,
|
LOG_LEVEL_MESSAGE,
|
||||||
LOG_LEVEL_WARNING,
|
LOG_LEVEL_WARNING,
|
||||||
LOG_LEVEL_ERROR,
|
LOG_LEVEL_ERROR,
|
||||||
|
LOG_LEVEL_IMPORTANT,
|
||||||
LOG_LEVEL_NONE,
|
LOG_LEVEL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ public:
|
|||||||
void log_message(const String &str);
|
void log_message(const String &str);
|
||||||
void log_warning(const String &str);
|
void log_warning(const String &str);
|
||||||
void log_error(const String &str);
|
void log_error(const String &str);
|
||||||
|
void log_important(const String &str);
|
||||||
|
|
||||||
LogLevel get_log_level();
|
LogLevel get_log_level();
|
||||||
void set_log_level(const LogLevel p_log_level);
|
void set_log_level(const LogLevel p_log_level);
|
||||||
|
@ -278,6 +278,67 @@ void PLogger::log_error(const char *p_function, const char *p_file, int p_line,
|
|||||||
do_log_error(s);
|
do_log_error(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PLogger::log_important(const String &str) {
|
||||||
|
if (_log_level > LOG_LEVEL_IMPORTANT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String s;
|
||||||
|
s += "I ";
|
||||||
|
s += str;
|
||||||
|
//s += "\n";
|
||||||
|
|
||||||
|
do_log_important(s);
|
||||||
|
}
|
||||||
|
void PLogger::log_important(const char *str) {
|
||||||
|
if (_log_level > LOG_LEVEL_IMPORTANT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String s;
|
||||||
|
s += "I ";
|
||||||
|
s += str;
|
||||||
|
//s += "\n";
|
||||||
|
|
||||||
|
do_log_important(s);
|
||||||
|
}
|
||||||
|
void PLogger::log_important(const char *p_function, const char *p_file, int p_line, const char *str) {
|
||||||
|
if (_log_level > LOG_LEVEL_IMPORTANT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String s;
|
||||||
|
s += "I | ";
|
||||||
|
s += p_file;
|
||||||
|
s += "::";
|
||||||
|
s += p_function;
|
||||||
|
s += ":";
|
||||||
|
s += String::num(p_line);
|
||||||
|
s += " | ";
|
||||||
|
s += str;
|
||||||
|
//s += "\n";
|
||||||
|
|
||||||
|
do_log_important(s);
|
||||||
|
}
|
||||||
|
void PLogger::log_important(const char *p_function, const char *p_file, int p_line, const String &str) {
|
||||||
|
if (_log_level > LOG_LEVEL_IMPORTANT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String s;
|
||||||
|
s += "I | ";
|
||||||
|
s += p_file;
|
||||||
|
s += "::";
|
||||||
|
s += p_function;
|
||||||
|
s += ":";
|
||||||
|
s += String::num(p_line);
|
||||||
|
s += " | ";
|
||||||
|
s += str;
|
||||||
|
//s += "\n";
|
||||||
|
|
||||||
|
do_log_important(s);
|
||||||
|
}
|
||||||
|
|
||||||
void PLogger::do_log_trace(const String &str) {
|
void PLogger::do_log_trace(const String &str) {
|
||||||
if (_backend.is_valid()) {
|
if (_backend.is_valid()) {
|
||||||
_backend->log_trace(str);
|
_backend->log_trace(str);
|
||||||
@ -310,6 +371,14 @@ void PLogger::do_log_error(const String &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PLogger::do_log_important(const String &str) {
|
||||||
|
if (_backend.is_valid()) {
|
||||||
|
_backend->log_important(str);
|
||||||
|
} else {
|
||||||
|
force_print_error(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PLogger::LogLevel PLogger::get_log_level() {
|
PLogger::LogLevel PLogger::get_log_level() {
|
||||||
return _log_level;
|
return _log_level;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,9 @@ class String;
|
|||||||
#define PLOG_ERR(str) \
|
#define PLOG_ERR(str) \
|
||||||
PLogger::log_error(__FUNCTION__, __FILE__, __LINE__, str);
|
PLogger::log_error(__FUNCTION__, __FILE__, __LINE__, str);
|
||||||
|
|
||||||
|
#define PLOG_IMPORTANT(str) \
|
||||||
|
PLogger::log_important(__FUNCTION__, __FILE__, __LINE__, str);
|
||||||
|
|
||||||
class PLogger : public Object {
|
class PLogger : public Object {
|
||||||
public:
|
public:
|
||||||
enum LogLevel {
|
enum LogLevel {
|
||||||
@ -58,6 +61,7 @@ public:
|
|||||||
LOG_LEVEL_MESSAGE,
|
LOG_LEVEL_MESSAGE,
|
||||||
LOG_LEVEL_WARNING,
|
LOG_LEVEL_WARNING,
|
||||||
LOG_LEVEL_ERROR,
|
LOG_LEVEL_ERROR,
|
||||||
|
LOG_LEVEL_IMPORTANT,
|
||||||
LOG_LEVEL_NONE,
|
LOG_LEVEL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,10 +85,16 @@ public:
|
|||||||
static void log_error(const char *p_function, const char *p_file, int p_line, const char *str);
|
static void log_error(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||||
static void log_error(const char *p_function, const char *p_file, int p_line, const String &str);
|
static void log_error(const char *p_function, const char *p_file, int p_line, const String &str);
|
||||||
|
|
||||||
|
static void log_important(const String &str);
|
||||||
|
static void log_important(const char *str);
|
||||||
|
static void log_important(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||||
|
static void log_important(const char *p_function, const char *p_file, int p_line, const String &str);
|
||||||
|
|
||||||
static void do_log_trace(const String &str);
|
static void do_log_trace(const String &str);
|
||||||
static void do_log_message(const String &str);
|
static void do_log_message(const String &str);
|
||||||
static void do_log_warning(const String &str);
|
static void do_log_warning(const String &str);
|
||||||
static void do_log_error(const String &str);
|
static void do_log_error(const String &str);
|
||||||
|
static void do_log_important(const String &str);
|
||||||
|
|
||||||
static LogLevel get_log_level();
|
static LogLevel get_log_level();
|
||||||
static void set_log_level(const LogLevel p_log_level);
|
static void set_log_level(const LogLevel p_log_level);
|
||||||
|
@ -45,6 +45,9 @@ void LoggerBackend::log_warning(const String &str) {
|
|||||||
void LoggerBackend::log_error(const String &str) {
|
void LoggerBackend::log_error(const String &str) {
|
||||||
call("_log_error", str);
|
call("_log_error", str);
|
||||||
}
|
}
|
||||||
|
void LoggerBackend::log_important(const String &str) {
|
||||||
|
call("_log_important", str);
|
||||||
|
}
|
||||||
|
|
||||||
void LoggerBackend::_log_trace(const String &str) {
|
void LoggerBackend::_log_trace(const String &str) {
|
||||||
print_line(str);
|
print_line(str);
|
||||||
@ -58,6 +61,9 @@ void LoggerBackend::_log_warning(const String &str) {
|
|||||||
void LoggerBackend::_log_error(const String &str) {
|
void LoggerBackend::_log_error(const String &str) {
|
||||||
print_error(str);
|
print_error(str);
|
||||||
}
|
}
|
||||||
|
void LoggerBackend::_log_important(const String &str) {
|
||||||
|
print_error(str);
|
||||||
|
}
|
||||||
|
|
||||||
LoggerBackend::LoggerBackend() {
|
LoggerBackend::LoggerBackend() {
|
||||||
}
|
}
|
||||||
@ -70,14 +76,17 @@ void LoggerBackend::_bind_methods() {
|
|||||||
BIND_VMETHOD(MethodInfo("_log_message", PropertyInfo(Variant::STRING, "str")));
|
BIND_VMETHOD(MethodInfo("_log_message", PropertyInfo(Variant::STRING, "str")));
|
||||||
BIND_VMETHOD(MethodInfo("_log_warning", PropertyInfo(Variant::STRING, "str")));
|
BIND_VMETHOD(MethodInfo("_log_warning", PropertyInfo(Variant::STRING, "str")));
|
||||||
BIND_VMETHOD(MethodInfo("_log_error", PropertyInfo(Variant::STRING, "str")));
|
BIND_VMETHOD(MethodInfo("_log_error", PropertyInfo(Variant::STRING, "str")));
|
||||||
|
BIND_VMETHOD(MethodInfo("_log_important", PropertyInfo(Variant::STRING, "str")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("log_trace", "str"), &LoggerBackend::log_trace);
|
ClassDB::bind_method(D_METHOD("log_trace", "str"), &LoggerBackend::log_trace);
|
||||||
ClassDB::bind_method(D_METHOD("log_message", "str"), &LoggerBackend::log_message);
|
ClassDB::bind_method(D_METHOD("log_message", "str"), &LoggerBackend::log_message);
|
||||||
ClassDB::bind_method(D_METHOD("log_warning", "str"), &LoggerBackend::log_warning);
|
ClassDB::bind_method(D_METHOD("log_warning", "str"), &LoggerBackend::log_warning);
|
||||||
ClassDB::bind_method(D_METHOD("log_error", "str"), &LoggerBackend::log_error);
|
ClassDB::bind_method(D_METHOD("log_error", "str"), &LoggerBackend::log_error);
|
||||||
|
ClassDB::bind_method(D_METHOD("log_important", "str"), &LoggerBackend::log_important);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_log_trace", "str"), &LoggerBackend::_log_trace);
|
ClassDB::bind_method(D_METHOD("_log_trace", "str"), &LoggerBackend::_log_trace);
|
||||||
ClassDB::bind_method(D_METHOD("_log_message", "str"), &LoggerBackend::_log_message);
|
ClassDB::bind_method(D_METHOD("_log_message", "str"), &LoggerBackend::_log_message);
|
||||||
ClassDB::bind_method(D_METHOD("_log_warning", "str"), &LoggerBackend::_log_warning);
|
ClassDB::bind_method(D_METHOD("_log_warning", "str"), &LoggerBackend::_log_warning);
|
||||||
ClassDB::bind_method(D_METHOD("_log_error", "str"), &LoggerBackend::_log_error);
|
ClassDB::bind_method(D_METHOD("_log_error", "str"), &LoggerBackend::_log_error);
|
||||||
|
ClassDB::bind_method(D_METHOD("_log_important", "str"), &LoggerBackend::_log_important);
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,13 @@ public:
|
|||||||
virtual void log_message(const String &str);
|
virtual void log_message(const String &str);
|
||||||
virtual void log_warning(const String &str);
|
virtual void log_warning(const String &str);
|
||||||
virtual void log_error(const String &str);
|
virtual void log_error(const String &str);
|
||||||
|
virtual void log_important(const String &str);
|
||||||
|
|
||||||
virtual void _log_trace(const String &str);
|
virtual void _log_trace(const String &str);
|
||||||
virtual void _log_message(const String &str);
|
virtual void _log_message(const String &str);
|
||||||
virtual void _log_warning(const String &str);
|
virtual void _log_warning(const String &str);
|
||||||
virtual void _log_error(const String &str);
|
virtual void _log_error(const String &str);
|
||||||
|
virtual void _log_important(const String &str);
|
||||||
|
|
||||||
LoggerBackend();
|
LoggerBackend();
|
||||||
~LoggerBackend();
|
~LoggerBackend();
|
||||||
|
Loading…
Reference in New Issue
Block a user