Also added print_ methods to the logger, and the PRINT macros now call those.

This commit is contained in:
Relintai 2022-02-15 13:08:18 +01:00
parent 683359a2af
commit 0fbbfe2cdd
3 changed files with 86 additions and 4 deletions

View File

@ -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(...) \
{ \

View File

@ -8,6 +8,66 @@
#include <stdio.h>
#include <thread>
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());
}

View File

@ -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);