From fb125bac9d2ea5c39685d1ec3124dcfe9e432adc Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 11 Jun 2022 17:15:51 +0200 Subject: [PATCH] Binder class for the logger. --- core/log/logger_bind.cpp | 76 ++++++++++++++++++++++++++++++++++++++++ core/log/logger_bind.h | 50 ++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 core/log/logger_bind.cpp create mode 100644 core/log/logger_bind.h diff --git a/core/log/logger_bind.cpp b/core/log/logger_bind.cpp new file mode 100644 index 000000000..e107846e9 --- /dev/null +++ b/core/log/logger_bind.cpp @@ -0,0 +1,76 @@ + +#include "logger_bind.h" + +#include "logger.h" + +Ref _PLogger::get_backend() { + return PLogger::_backend; +} +void _PLogger::set_backend(const Ref &backend) { + PLogger::_backend = backend; +} + +void _PLogger::log_trace(const String &str) { + PLogger::log_trace(str); +} +void _PLogger::log_trace(const char *str) { + PLogger::log_trace(str); +} +void _PLogger::log_trace(const char *p_function, const char *p_file, int p_line, const char *str) { + PLogger::log_trace(p_function, p_file, p_line, str); +} +void _PLogger::log_trace(const char *p_function, const char *p_file, int p_line, const String &str) { + PLogger::log_trace(p_function, p_file, p_line, str); +} + +void _PLogger::log_message(const String &str) { + PLogger::log_message(str); +} +void _PLogger::log_message(const char *str) { + PLogger::log_message(str); +} +void _PLogger::log_message(const char *p_function, const char *p_file, int p_line, const char *str) { + PLogger::log_message(p_function, p_file, p_line, str); +} +void _PLogger::log_message(const char *p_function, const char *p_file, int p_line, const String &str) { + PLogger::log_message(p_function, p_file, p_line, str); +} + +void _PLogger::log_warning(const String &str) { + PLogger::log_warning(str); +} +void _PLogger::log_warning(const char *str) { + PLogger::log_warning(str); +} +void _PLogger::log_warning(const char *p_function, const char *p_file, int p_line, const char *str) { + PLogger::log_warning(p_function, p_file, p_line, str); +} +void _PLogger::log_warning(const char *p_function, const char *p_file, int p_line, const String &str) { + PLogger::log_warning(p_function, p_file, p_line, str); +} + +void _PLogger::log_error(const String &str) { + PLogger::log_error(str); +} +void _PLogger::log_error(const char *str) { + PLogger::log_error(str); +} +void _PLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *str) { + PLogger::log_error(p_function, p_file, p_line, str); +} +void _PLogger::log_error(const char *p_function, const char *p_file, int p_line, const String &str) { + PLogger::log_error(p_function, p_file, p_line, str); +} + +_PLogger *_PLogger::get_singleton() { + return _self; +} + +_PLogger::_PLogger() { + _self = this; +} +_PLogger::~_PLogger() { + _self = nullptr; +} + +_PLogger *_PLogger::_self = nullptr; diff --git a/core/log/logger_bind.h b/core/log/logger_bind.h new file mode 100644 index 000000000..6d555ab9f --- /dev/null +++ b/core/log/logger_bind.h @@ -0,0 +1,50 @@ + +#ifndef PLOGGER_BIND_H +#define PLOGGER_BIND_H + +#include "core/reference.h" +#include "core/typedefs.h" +#include "core/ustring.h" +#include "logger_backend.h" + +class String; + +class _PLogger : public Object { + GDCLASS(_PLogger, Object); + +public: + Ref get_backend(); + void set_backend(const Ref &backend); + + void log_trace(const String &str); + void log_trace(const char *str); + void log_trace(const char *p_function, const char *p_file, int p_line, const String &str); + void log_trace(const char *p_function, const char *p_file, int p_line, const char *str); + + void log_message(const String &str); + void log_message(const char *str); + void log_message(const char *p_function, const char *p_file, int p_line, const String &str); + void log_message(const char *p_function, const char *p_file, int p_line, const char *str); + + void log_warning(const String &str); + void log_warning(const char *str); + void log_warning(const char *p_function, const char *p_file, int p_line, const String &str); + void log_warning(const char *p_function, const char *p_file, int p_line, const char *str); + + void log_error(const String &str); + void log_error(const char *str); + void log_error(const char *p_function, const char *p_file, int p_line, const char *str); + void log_error(const char *p_function, const char *p_file, int p_line, const String &str); + + static _PLogger *get_singleton(); + + _PLogger(); + ~_PLogger(); + +protected: + static void _bind_methods(); + + static _PLogger *_self; +}; + +#endif