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)
25test_log_callback(
LogEvent *ev,
void *user_data)
28 last_level = ev->
level;
31 int r = vsnprintf(last_msg,
sizeof(last_msg), ev->
fmt, ev->
ap);
43 EXPECT(callback_hits == 1);
45 EXPECT(strcmp(last_msg,
"Hello World") == 0);
54 LOG_INFO(
"This should be ignored entirely");
55 EXPECT(callback_hits == 1);
59 EXPECT(callback_hits == 2);
61 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 log_set_level(LogLevel level)
Configures the active logging level. Messages below this level are ignored.
void log_set_lock(LogLockFn fn, void *user_data)
Configures thread-safety by providing a custom locking mechanism.
LogLevel
The severity level of a log message.
b32 log_add_callback(LogFn fn, void *user_data, LogLevel min_level)
Adds a custom callback function as a logging destination.
void log_set_quiet(b32 enable)
Mutes or unmutes all console (stdout/stderr) output.
A structured event containing all metadata for a single log message.
A lightweight, dependency-free unit testing harness.
#define EXPECT(cond)
Evaluates a condition. If it fails, prints the file/line and increments the fail count.
#define TEST_CASE(name)
Defines a test case function.