base: Added some extra logging macros
LOG, LOG_ERR. LOG_ERR will always compile to a /stderr/ print. LOG, on the other hand, may not actually do anything if VERBOSE_LOGS is not 1. By default it is 0, so it must be defined when compiling to enable - hence the adjustment of the Makefile.
This commit is contained in:
2
Makefile
2
Makefile
@@ -9,7 +9,7 @@ OBJECTS:=$(patsubst %,$(DIST)/%.o, $(UNITS))
|
||||
|
||||
LDFLAGS=
|
||||
GFLAGS=-Wall -Wextra -Wpedantic -std=c23 -I./include/
|
||||
DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined
|
||||
DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined -DVERBOSE_LOGS=1
|
||||
RFLAGS=-O3
|
||||
|
||||
MODE=release
|
||||
|
||||
@@ -33,13 +33,35 @@ typedef double f64;
|
||||
#define MIN(A, B) ((A) > (B) ? (B) : (A))
|
||||
#define ARRSIZE(A) ((sizeof(A)) / sizeof((A)[0]))
|
||||
|
||||
#ifndef VERBOSE_LOGS
|
||||
#define VERBOSE_LOGS 0
|
||||
#endif
|
||||
|
||||
#if VERBOSE_LOGS
|
||||
#define LOG(...) \
|
||||
do \
|
||||
{ \
|
||||
fprintf(stdout, "LOG: "); \
|
||||
fprintf(stdout, __VA_ARGS__); \
|
||||
} while (0);
|
||||
#else
|
||||
#define LOG(...)
|
||||
#endif
|
||||
|
||||
#define LOG_ERR(...) \
|
||||
do \
|
||||
{ \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while (0);
|
||||
|
||||
#define FAIL(...) \
|
||||
do \
|
||||
{ \
|
||||
fprintf(stderr, "FAIL: "); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
LOG_ERR("FAIL: "); \
|
||||
LOG_ERR(__VA_ARGS__); \
|
||||
assert(0); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 2026 Aryadev Chavali
|
||||
|
||||
Reference in New Issue
Block a user