From 0fbbfe2cdd9aca0c3cd1f1af92a7b5e60fbfa061 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 15 Feb 2022 13:08:18 +0100 Subject: [PATCH] Also added print_ methods to the logger, and the PRINT macros now call those. --- core/error_macros.h | 8 +++--- core/log/logger.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++ core/log/logger.h | 22 +++++++++++++++++ 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/core/error_macros.h b/core/error_macros.h index cfe29e0..aa4369e 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -66,7 +66,7 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E } #define RPRINT_TRACE(str) \ - RLogger::log_trace(__FUNCTION__, __FILE__, __LINE__, str); + RLogger::print_trace(__FUNCTION__, __FILE__, __LINE__, str); #define RLOG_TRACE(...) \ { \ @@ -76,7 +76,7 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E } #define RPRINT_MSG(str) \ - RLogger::log_message(__FUNCTION__, __FILE__, __LINE__, str); + RLogger::print_message(__FUNCTION__, __FILE__, __LINE__, str); #define RLOG_MSG(...) \ { \ @@ -86,7 +86,7 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E } #define RPRINT_WARN(str) \ - RLogger::log_warning(__FUNCTION__, __FILE__, __LINE__, str); + RLogger::print_warning(__FUNCTION__, __FILE__, __LINE__, str); #define RLOG_WARN(...) \ { \ @@ -96,7 +96,7 @@ _FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E } #define RPRINT_ERR(str) \ - RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, str); + RLogger::print_error(__FUNCTION__, __FILE__, __LINE__, str); #define RLOG_ERR(...) \ { \ diff --git a/core/log/logger.cpp b/core/log/logger.cpp index 8b15cc4..d9149be 100644 --- a/core/log/logger.cpp +++ b/core/log/logger.cpp @@ -8,6 +8,66 @@ #include #include + +void RLogger::print_trace(const String &str) { + print_trace(str.data()); +} +void RLogger::print_trace(const char *str) { + printf("T %s\n", str); +} +void RLogger::print_trace(const char *p_function, const char *p_file, int p_line, const char *str) { + printf("T | %s::%s:%d | %s\n", p_file, p_function, p_line, str); +} +void RLogger::print_trace(const char *p_function, const char *p_file, int p_line, const String &str) { + printf("T | %s::%s:%d | %s\n", p_file, p_function, p_line, str.c_str()); +} + +void RLogger::print_message(const String &str) { + print_message(str.data()); +} +void RLogger::print_message(const char *str) { + printf("M %s\n", str); +} +void RLogger::print_message(const char *p_function, const char *p_file, int p_line, const char *str) { + printf("M | %s::%s:%d | %s\n", p_file, p_function, p_line, str); +} +void RLogger::print_message(const char *p_function, const char *p_file, int p_line, const String &str) { + printf("M | %s::%s:%d | %s\n", p_file, p_function, p_line, str.c_str()); +} + +void RLogger::print_warning(const String &str) { + print_warning(str.data()); +} +void RLogger::print_warning(const char *str) { + printf("W %s\n", str); +} +void RLogger::print_warning(const char *p_function, const char *p_file, int p_line, const char *str) { + printf("W | %s::%s:%d | %s\n", p_file, p_function, p_line, str); +} +void RLogger::print_warning(const char *p_function, const char *p_file, int p_line, const String &str) { + printf("W | %s::%s:%d | %s\n", p_file, p_function, p_line, str.c_str()); +} + +void RLogger::print_error(const String &str) { + print_error(str.data()); +} +void RLogger::print_error(const char *str) { + printf("E %s\n", str); +} + +void RLogger::print_error(const char *p_function, const char *p_file, int p_line, const char *str) { + printf("E | %s::%s:%d | %s\n", p_file, p_function, p_line, str); +} +void RLogger::print_error(const char *p_function, const char *p_file, int p_line, const String &str) { + printf("E | %s::%s:%d | %s\n", p_file, p_function, p_line, str.c_str()); +} +void RLogger::print_msg_error(const char *p_function, const char *p_file, int p_line, const char *p_msg, const char *str) { + printf("E | %s::%s:%d | :: %s. %s\n", p_file, p_function, p_line, str, p_msg); +} +void RLogger::print_index_error(const char *p_function, const char *p_file, int p_line, const int index, const int size, const char *str) { + printf("E (INDEX) | %s::%s:%d | :: index: %d/%d. %s\n", p_file, p_function, p_line, index, size, str); +} + void RLogger::log_trace(const String &str) { log_trace(str.data()); } diff --git a/core/log/logger.h b/core/log/logger.h index 829852b..c45aa32 100644 --- a/core/log/logger.h +++ b/core/log/logger.h @@ -11,6 +11,28 @@ class String; class RLogger { public: + static void print_trace(const String &str); + static void print_trace(const char *str); + static void print_trace(const char *p_function, const char *p_file, int p_line, const String &str); + static void print_trace(const char *p_function, const char *p_file, int p_line, const char *str); + + static void print_message(const String &str); + static void print_message(const char *str); + static void print_message(const char *p_function, const char *p_file, int p_line, const String &str); + static void print_message(const char *p_function, const char *p_file, int p_line, const char *str); + + static void print_warning(const String &str); + static void print_warning(const char *str); + static void print_warning(const char *p_function, const char *p_file, int p_line, const String &str); + static void print_warning(const char *p_function, const char *p_file, int p_line, const char *str); + + static void print_error(const String &str); + static void print_error(const char *str); + static void print_error(const char *p_function, const char *p_file, int p_line, const char *str); + static void print_error(const char *p_function, const char *p_file, int p_line, const String &str); + static void print_msg_error(const char *p_function, const char *p_file, int p_line, const char *p_msg, const char *str); + static void print_index_error(const char *p_function, const char *p_file, int p_line, const int index, const int size, const char *str); + static void log_trace(const String &str); static void log_trace(const char *str); static void log_trace(const char *p_function, const char *p_file, int p_line, const String &str);