fixup: more logging code
This commit is contained in:
@@ -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++) {
|
||||||
|
|||||||
@@ -22,21 +22,24 @@ 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); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#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__); \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user