fixup: more logging code
This commit is contained in:
@@ -1,5 +1,28 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/common.h"
|
||||
|
||||
__attribute__((weak))
|
||||
void gb_log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void gb_error(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void downcase(char *str)
|
||||
{
|
||||
for (int i = 0; str[i] != '\0'; i++) {
|
||||
|
||||
@@ -22,21 +22,24 @@ void downcase(char *str);
|
||||
#define DEBUG_ON 0
|
||||
#endif
|
||||
|
||||
void gb_log(const char *fmt, ...);
|
||||
void gb_error(const char *fmt, ...);
|
||||
|
||||
#define QUOTE(...) #__VA_ARGS__
|
||||
|
||||
#define ASSERT(x) \
|
||||
if (!(x) && DEBUG_ON) { \
|
||||
printf("Assert at: %s:%d <%s> : %s\n", \
|
||||
__FILE__, __LINE__, \
|
||||
__func__, #x); \
|
||||
gb_error("Assert at: %s:%d <%s> : %s\n", \
|
||||
__FILE__, __LINE__, \
|
||||
__func__, #x); \
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
#define ASSERT_MSG(x,...) \
|
||||
if(!(x) && DEBUG_ON) { \
|
||||
printf("Assert at: %s:%d <%s> : %s\n", \
|
||||
__FILE__, __LINE__, \
|
||||
__func__, #x); \
|
||||
gb_error("Assert at: %s:%d <%s> : %s\n", \
|
||||
__FILE__, __LINE__, \
|
||||
__func__, #x); \
|
||||
printf(__VA_ARGS__); \
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user