diff --git a/src/common/common.c b/src/common/common.c index 9f95431..0bdefb2 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -1,5 +1,28 @@ +#include +#include + #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++) { diff --git a/src/common/common.h b/src/common/common.h index 7f6102a..b7280a7 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -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); \ }