From f911a9b363133776fcf65cc6ab01f37dd7a0d6ce Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 11 Jun 2022 18:01:27 +0200 Subject: [PATCH] Implement all the logging methods. --- core/log/logger.cpp | 130 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 6 deletions(-) diff --git a/core/log/logger.cpp b/core/log/logger.cpp index bac9a33f8..fb1f51e53 100644 --- a/core/log/logger.cpp +++ b/core/log/logger.cpp @@ -8,7 +8,7 @@ void PLogger::log_trace(const String &str) { String s; s += "T "; s += str; - s += "\n"; + //s += "\n"; do_log_trace(s); } @@ -16,7 +16,7 @@ void PLogger::log_trace(const char *str) { String s; s += "T "; s += str; - s += "\n"; + //s += "\n"; do_log_trace(s); } @@ -27,43 +27,161 @@ void PLogger::log_trace(const char *p_function, const char *p_file, int p_line, s += "::"; s += p_function; s += ":"; - s += p_line; + s += String::num(p_line); s += " | "; s += str; - s += "\n"; + //s += "\n"; do_log_trace(s); - - printf("T | %s::%s:%d | %s\n", p_file, p_function, p_line, str); } void PLogger::log_trace(const char *p_function, const char *p_file, int p_line, const String &str) { + String s; + s += "T | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_message(const String &str) { + String s; + s += "M "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_message(const char *str) { + String s; + s += "M "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_message(const char *p_function, const char *p_file, int p_line, const char *str) { + String s; + s += "M | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_message(const char *p_function, const char *p_file, int p_line, const String &str) { + String s; + s += "M | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_warning(const String &str) { + String s; + s += "W "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_warning(const char *str) { + String s; + s += "W "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_warning(const char *p_function, const char *p_file, int p_line, const char *str) { + String s; + s += "W | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_warning(const char *p_function, const char *p_file, int p_line, const String &str) { + String s; + s += "W | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_error(const String &str) { + String s; + s += "E "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_error(const char *str) { + String s; + s += "E "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *str) { + String s; + s += "E | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::log_error(const char *p_function, const char *p_file, int p_line, const String &str) { + String s; + s += "E | "; + s += p_file; + s += "::"; + s += p_function; + s += ":"; + s += String::num(p_line); + s += " | "; + s += str; + //s += "\n"; + + do_log_trace(s); } void PLogger::do_log_trace(const String &str) {