fixup: more logging code

This commit is contained in:
2018-07-22 16:17:36 -07:00
parent e1e3111976
commit 9c8c3bda9e
2 changed files with 32 additions and 6 deletions

View File

@@ -1,5 +1,28 @@
#include <stdarg.h>
#include <stdio.h>
#include "common/common.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) void downcase(char *str)
{ {
for (int i = 0; str[i] != '\0'; i++) { for (int i = 0; str[i] != '\0'; i++) {

View File

@@ -22,11 +22,14 @@ void downcase(char *str);
#define DEBUG_ON 0 #define DEBUG_ON 0
#endif #endif
void gb_log(const char *fmt, ...);
void gb_error(const char *fmt, ...);
#define QUOTE(...) #__VA_ARGS__ #define QUOTE(...) #__VA_ARGS__
#define ASSERT(x) \ #define ASSERT(x) \
if (!(x) && DEBUG_ON) { \ if (!(x) && DEBUG_ON) { \
printf("Assert at: %s:%d <%s> : %s\n", \ gb_error("Assert at: %s:%d <%s> : %s\n", \
__FILE__, __LINE__, \ __FILE__, __LINE__, \
__func__, #x); \ __func__, #x); \
exit(1); \ exit(1); \
@@ -34,7 +37,7 @@ void downcase(char *str);
#define ASSERT_MSG(x,...) \ #define ASSERT_MSG(x,...) \
if(!(x) && DEBUG_ON) { \ if(!(x) && DEBUG_ON) { \
printf("Assert at: %s:%d <%s> : %s\n", \ gb_error("Assert at: %s:%d <%s> : %s\n", \
__FILE__, __LINE__, \ __FILE__, __LINE__, \
__func__, #x); \ __func__, #x); \
printf(__VA_ARGS__); \ printf(__VA_ARGS__); \