6static int lock_calls = 0;
7static int unlock_calls = 0;
8static int callback_hits = 0;
10static char last_msg[256];
14test_lock_fn(
void *user_data,
b32 lock)
28 last_level = ev->
level;
31 int r = vsnprintf(last_msg,
sizeof(last_msg), ev->
fmt, ev->
ap);
32 EXPECT(r > 0 && r < (
int)
sizeof(last_msg));
44 EXPECT(callback_hits == 1);
46 EXPECT(strcmp(last_msg,
"Hello World") == 0);
55 LOG_INFO(
"This should be ignored entirely");
56 EXPECT(callback_hits == 1);
60 EXPECT(callback_hits == 2);
62 EXPECT(strcmp(last_msg,
"This should pass 42") == 0);
static void lock(void)
Acquires the logger lock if a locking function is configured.
Professional, thread-safe, leveled logging system.
#define LOG_INFO(...)
Logs an INFO level message (General application flow).
#define LOG_ERROR(...)
Logs an ERROR level message (Recoverable operation failures).
void base_log_set_quiet(b32 enable)
Mutes or unmutes all console (stdout/stderr) output.
void base_log_set_lock(BaseLogLockFn fn, void *user_data)
Configures thread-safety by providing a custom locking mechanism.
void base_log_set_level(BaseLogLevel level)
Configures the active logging level. Messages below this level are ignored.
b32 base_log_add_callback(BaseLogFn fn, void *user_data, BaseLogLevel min_level)
Adds a custom callback function as a logging destination.
BaseLogLevel
The severity level of a log message.
A structured event containing all metadata for a single log message.
Single-header testing framework with pretty-printed output.
#define EXPECT(cond)
Evaluates a condition. Records and counts the failure if false.
#define TEST_CASE(name)
Declares a test case function.