mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Cleaned up the logger's api a bit. Now the normal log macros will also print fie, line and method information.
This commit is contained in:
parent
71f8a12997
commit
58eb9f8252
@ -20,98 +20,98 @@
|
||||
#endif
|
||||
|
||||
#define RLOG_TRACE(str) \
|
||||
RLogger::log_trace(str);
|
||||
RLogger::log_trace(__FUNCTION__, __FILE__, __LINE__, str);
|
||||
|
||||
#define RLOG_MSG(str) \
|
||||
RLogger::log_message(str);
|
||||
RLogger::log_message(__FUNCTION__, __FILE__, __LINE__, str);
|
||||
|
||||
#define RLOG_WARN(str) \
|
||||
RLogger::log_warning(str);
|
||||
RLogger::log_warning(__FUNCTION__, __FILE__, __LINE__, str);
|
||||
|
||||
#define RLOG_ERR(str) \
|
||||
RLogger::log_error(str);
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, str);
|
||||
|
||||
#define ERR_FAIL_MSG(msg) \
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
return;
|
||||
|
||||
#define ERR_FAIL_V_MSG(val, msg) \
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
return val;
|
||||
|
||||
#define ERR_FAIL_INDEX(index, size) \
|
||||
if ((index < 0) || (index >= size)) {\
|
||||
RLogger::_log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, ""); \
|
||||
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, ""); \
|
||||
return;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_INDEX_MSG(index, size, msg) \
|
||||
if ((index < 0) || (index >= size)) {\
|
||||
RLogger::_log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, msg); \
|
||||
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, msg); \
|
||||
return;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_INDEX_V(index, size, val) \
|
||||
if ((index < 0) || (index >= size)) {\
|
||||
RLogger::_log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, ""); \
|
||||
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, ""); \
|
||||
return val;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_INDEX_V_MSG(index, size, val, msg) \
|
||||
if ((index < 0) || (index >= size)) {\
|
||||
RLogger::_log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, msg); \
|
||||
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, msg); \
|
||||
return val;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_COND(cond) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_FAIL_COND: \"" #cond "\" is true!"); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_FAIL_COND: \"" #cond "\" is true!"); \
|
||||
return;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_COND_MSG(cond, msg) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
return;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_COND_V(cond, val) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_FAIL_COND: \"" #cond "\" is true!"); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_FAIL_COND: \"" #cond "\" is true!"); \
|
||||
return val;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_FAIL_COND_V_MSG(cond, val, msg) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
return val;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_CONTINUE(cond) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_CONTINUE: \"" #cond "\" is true!"); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_CONTINUE: \"" #cond "\" is true!"); \
|
||||
continue;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_CONTINUE_MSG(cond, msg) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
continue;\
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define ERR_CONTINUE_ACTION(cond, action) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_CONTINUE: \"" #cond "\" is true!"); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, "ERR_CONTINUE: \"" #cond "\" is true!"); \
|
||||
action;\
|
||||
continue;\
|
||||
} else\
|
||||
@ -119,7 +119,7 @@
|
||||
|
||||
#define ERR_CONTINUE_ACTION_MSG(cond, action, msg) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, msg); \
|
||||
action;\
|
||||
continue;\
|
||||
} else\
|
||||
@ -127,14 +127,14 @@
|
||||
|
||||
#define CRASH_INDEX(index, size) \
|
||||
if ((index < 0) || (index >= size)) {\
|
||||
RLogger::_log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, "CRASH!"); \
|
||||
RLogger::log_index_error(__FUNCTION__, __FILE__, __LINE__, index, size, "CRASH!"); \
|
||||
GENERATE_TRAP \
|
||||
} else\
|
||||
((void)0)\
|
||||
|
||||
#define CRASH_COND(cond) \
|
||||
if (cond) {\
|
||||
RLogger::_log_error(__FUNCTION__, __FILE__, __LINE__, "CRASH_COND: \"" #cond "\" is true!"); \
|
||||
RLogger::log_error(__FUNCTION__, __FILE__, __LINE__, "CRASH_COND: \"" #cond "\" is true!"); \
|
||||
GENERATE_TRAP \
|
||||
} else\
|
||||
((void)0)\
|
||||
|
@ -14,6 +14,12 @@ void RLogger::log_trace(const String &str) {
|
||||
void RLogger::log_trace(const char *str) {
|
||||
printf("T %s\n", str);
|
||||
}
|
||||
void RLogger::log_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::log_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::log_message(const String &str) {
|
||||
log_message(str.data());
|
||||
@ -21,6 +27,12 @@ void RLogger::log_message(const String &str) {
|
||||
void RLogger::log_message(const char *str) {
|
||||
printf("M %s\n", str);
|
||||
}
|
||||
void RLogger::log_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::log_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::log_warning(const String &str) {
|
||||
log_warning(str.data());
|
||||
@ -28,6 +40,12 @@ void RLogger::log_warning(const String &str) {
|
||||
void RLogger::log_warning(const char *str) {
|
||||
printf("W %s\n", str);
|
||||
}
|
||||
void RLogger::log_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::log_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::log_error(const String &str) {
|
||||
log_error(str.data());
|
||||
@ -36,15 +54,15 @@ void RLogger::log_error(const char *str) {
|
||||
printf("E %s\n", str);
|
||||
}
|
||||
|
||||
void RLogger::_log_error(const char *p_function, const char *p_file, int p_line, const char *str) {
|
||||
printf("!ERROR: (%s) %s:%d. %s\n", p_file, p_function, p_line, str);
|
||||
void RLogger::log_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::_log_error(const char *p_function, const char *p_file, int p_line, const String &str) {
|
||||
printf("!ERROR: (%s) %s:%d. %s\n", p_file, p_function, p_line, str.c_str());
|
||||
void RLogger::log_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::_log_msg_error(const char *p_function, const char *p_file, int p_line, const char *p_msg, const char *str) {
|
||||
printf("!ERROR: (%s) %s:%d :: %s. %s\n", p_file, p_function, p_line, str, p_msg);
|
||||
void RLogger::log_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::_log_index_error(const char *p_function, const char *p_file, int p_line, const int index, const int size, const char *str) {
|
||||
printf("!INDEX ERROR: (%s) %s:%d :: index: %d/%d. %s\n", p_file, p_function, p_line, index, size, str);
|
||||
void RLogger::log_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);
|
||||
}
|
||||
|
@ -13,20 +13,26 @@ class RLogger {
|
||||
public:
|
||||
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);
|
||||
static void log_trace(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||
|
||||
static void log_message(const String &str);
|
||||
static void log_message(const char *str);
|
||||
static void log_message(const char *p_function, const char *p_file, int p_line, const String &str);
|
||||
static void log_message(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||
|
||||
static void log_warning(const String &str);
|
||||
static void log_warning(const char *str);
|
||||
static void log_warning(const char *p_function, const char *p_file, int p_line, const String &str);
|
||||
static void log_warning(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||
|
||||
static void log_error(const String &str);
|
||||
static void log_error(const char *str);
|
||||
static void log_error(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||
static void log_error(const char *p_function, const char *p_file, int p_line, const String &str);
|
||||
static void log_msg_error(const char *p_function, const char *p_file, int p_line, const char *p_msg, const char *str);
|
||||
static void log_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_error(const char *p_function, const char *p_file, int p_line, const char *str);
|
||||
static void _log_error(const char *p_function, const char *p_file, int p_line, const String &str);
|
||||
static void _log_msg_error(const char *p_function, const char *p_file, int p_line, const char *p_msg, const char *str);
|
||||
static void _log_index_error(const char *p_function, const char *p_file, int p_line, const int index, const int size, const char *str);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user