Implemented the LoggerBackend.

This commit is contained in:
Relintai 2022-06-11 16:54:55 +02:00
parent 26f0c17732
commit b52dd560ce
2 changed files with 52 additions and 2 deletions

View File

@ -1,6 +1,34 @@
#include "logger_backend.h"
#include "core/print_string.h"
void LoggerBackend::log_trace(const String &str) {
call("_log_trace", str);
}
void LoggerBackend::log_message(const String &str) {
call("_log_trace", str);
}
void LoggerBackend::log_warning(const String &str) {
call("_log_trace", str);
}
void LoggerBackend::log_error(const String &str) {
call("_log_trace", str);
}
void LoggerBackend::_log_trace(const String &str) {
print_line(str);
}
void LoggerBackend::_log_message(const String &str) {
print_line(str);
}
void LoggerBackend::_log_warning(const String &str) {
print_line(str);
}
void LoggerBackend::_log_error(const String &str) {
print_line(str);
}
LoggerBackend::LoggerBackend() {
}
@ -8,6 +36,18 @@ LoggerBackend::~LoggerBackend() {
}
void LoggerBackend::_bind_methods() {
//BIND_VMETHOD(MethodInfo(Variant::REAL, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
//ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &LoggerBackend::_get_property_value_sdf3d);
BIND_VMETHOD(MethodInfo("_log_trace", 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_error", PropertyInfo(Variant::STRING, "str")));
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_warning", "str"), &LoggerBackend::log_warning);
ClassDB::bind_method(D_METHOD("log_error", "str"), &LoggerBackend::log_error);
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_warning", "str"), &LoggerBackend::_log_warning);
ClassDB::bind_method(D_METHOD("_log_error", "str"), &LoggerBackend::_log_error);
}

View File

@ -10,6 +10,16 @@ class LoggerBackend : public Reference {
GDCLASS(LoggerBackend, Reference);
public:
virtual void log_trace(const String &str);
virtual void log_message(const String &str);
virtual void log_warning(const String &str);
virtual void log_error(const String &str);
virtual void _log_trace(const String &str);
virtual void _log_message(const String &str);
virtual void _log_warning(const String &str);
virtual void _log_error(const String &str);
LoggerBackend();
~LoggerBackend();