From f0f41218df2c98af52fcf68a975647c91a031c13 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 11 Jun 2022 18:07:21 +0200 Subject: [PATCH] Cleaned up the log macros. --- core/log/logger.h | 98 ++++++----------------------------------------- 1 file changed, 12 insertions(+), 86 deletions(-) diff --git a/core/log/logger.h b/core/log/logger.h index 99d919a10..7ff881be7 100644 --- a/core/log/logger.h +++ b/core/log/logger.h @@ -9,6 +9,18 @@ class String; +#define PLOG_TRACE(str) \ + PLogger::log_trace(__FUNCTION__, __FILE__, __LINE__, str); + +#define PLOG_MSG(str) \ + PLogger::log_message(__FUNCTION__, __FILE__, __LINE__, str); + +#define PLOG_WARN(str) \ + PLogger::log_warning(__FUNCTION__, __FILE__, __LINE__, str); + +#define PLOG_ERR(str) \ + PLogger::log_error(__FUNCTION__, __FILE__, __LINE__, str); + class PLogger : public Object { public: static void log_trace(const String &str); @@ -39,90 +51,4 @@ public: static Ref _backend; }; -// template methods for the variadic log macros. Add more as needed. -template -_FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0) { - str->append(p0); -} - -template -_FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1) { - str->append(p0); - str->push_back(' '); - str->append(p1); -} - -template -_FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2) { - str->append(p0); - str->push_back(' '); - str->append(p1); - str->push_back(' '); - str->append(p2); -} - -template -_FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3) { - str->append(p0); - str->push_back(' '); - str->append(p1); - str->push_back(' '); - str->append(p2); - str->push_back(' '); - str->append(p3); -} - -template -_FORCE_INLINE_ void _RLOG_MACRO_TEMPLATE_FUNC(STR str, A p0, B p1, C p2, D p3, E p4) { - str->append(p0); - str->push_back(' '); - str->append(p1); - str->push_back(' '); - str->append(p2); - str->push_back(' '); - str->append(p3); - str->push_back(' '); - str->append(p4); -} - -#define PLOG_TRACE(str) \ - PLogger::print_trace(__FUNCTION__, __FILE__, __LINE__, str); - -#define PALOG_TRACE(...) \ - { \ - String *_rlogger_string_ptr = PLogger::get_trace_string_ptr(__FUNCTION__, __FILE__, __LINE__); \ - _RLOG_MACRO_TEMPLATE_FUNC(_rlogger_string_ptr, __VA_ARGS__); \ - PLogger::log_ret_ptr(_rlogger_string_ptr); \ - } - -#define PLOG_MSG(str) \ - PLogger::print_message(__FUNCTION__, __FILE__, __LINE__, str); - -#define PALOG_MSG(...) \ - { \ - String *_rlogger_string_ptr = PLogger::get_message_string_ptr(__FUNCTION__, __FILE__, __LINE__); \ - _RLOG_MACRO_TEMPLATE_FUNC(_rlogger_string_ptr, __VA_ARGS__); \ - PLogger::log_ret_ptr(_rlogger_string_ptr); \ - } - -#define PLOG_WARN(str) \ - PLogger::print_warning(__FUNCTION__, __FILE__, __LINE__, str); - -#define PALOG_WARN(...) \ - { \ - String *_rlogger_string_ptr = PLogger::get_warning_string_ptr(__FUNCTION__, __FILE__, __LINE__); \ - _RLOG_MACRO_TEMPLATE_FUNC(_rlogger_string_ptr, __VA_ARGS__); \ - PLogger::log_ret_ptr(_rlogger_string_ptr); \ - } - -#define PLOG_ERR(str) \ - PLogger::print_error(__FUNCTION__, __FILE__, __LINE__, str); - -#define PALOG_ERR(...) \ - { \ - String *_rlogger_string_ptr = PLogger::get_error_string_ptr(__FUNCTION__, __FILE__, __LINE__); \ - _RLOG_MACRO_TEMPLATE_FUNC(_rlogger_string_ptr, __VA_ARGS__); \ - PLogger::log_ret_ptr(_rlogger_string_ptr); \ - } - #endif