Radikant Log C

Screenshot%202025 11 30%20at%2023.01.45

Radikant Log  is a logging library that utilizes preprocessor macros to fully strip log calls at compile time for zero-overhead production builds. It features thread-safe writing to both console and files with rich formatting, hex dumps, and flexible support for both global singletons and isolated logging contexts.

Example


int main() {
    rlog_init_global_file("app.log");
    log_info("Application started"); 
    log_success("Database connected");
    log_error("Failed to load configuration file");
    log_failure("Unhandled exception occurred");
    log_alert("System resources critically low");
    log_warning("Deprecated API usage detected");   
    return 0;
}
    
23:32:00 [INFO] Application started (/Users/charrlie/Desktop/Radikant-Log-C/test/test_log.c:87) 23:32:00 [SUCCESS] Database connected (/Users/charrlie/Desktop/Radikant-Log-C/test/test_log.c:88) 23:32:00 [ERROR] Failed to load configuration file (/Users/charrlie/Desktop/Radikant-Log-C/test/test_log.c:89) 23:32:00 [FAILURE] Unhandled exception occurred (/Users/charrlie/Desktop/Radikant-Log-C/test/test_log.c:90) 23:32:00 [ALERT] System resources critically low (/Users/charrlie/Desktop/Radikant-Log-C/test/test_log.c:91) 23:32:00 [WARN] Deprecated API usage detected (/Users/charrlie/Desktop/Radikant-Log-C/test/test_log.c:92)

Zero-Cost Abstraction

If  not enabled all logging macros expand to empty loops and will be removed from the binary.

Level Filtering

Filter debug messages at runtime to prevent verbose screen

Thread Safety

Abstracts mutex locking to ensure log messages don't get scrambled when accessed by multiple threads.

Compile-Time Stripping

Define Log Levels, the macros will remove unused logging functions from runtime.

Context Logging

Use context instances, allow different parts of your program to have different log levels.

File Logging

Log to one ore more files as astream simultaneously and independentily withouth any issues

File logging


    g_net_ctx = rlog_create_context("/Users/charrlie/Desktop/network.log", RLOG_SEV_ALL); 
    g_db_ctx = rlog_create_context("/Users/charrlie/Desktop/database.log", RLOG_SEV_ALL); 

    clog_info(g_net_ctx, "Interface initialization complete.");
    clog_warning(g_net_ctx, "High latency detected on port 8080."); 
    clog_failure(g_net_ctx, "High cpu usage detected on remote 2");
    clog_error(g_net_ctx, "Connection 2 is lost");

    clog_info(g_db_ctx, "Transaction started for user ID 10.");
    clog_error(g_db_ctx, "SQL insert failed: Duplicate key.");
    clog_error(g_db_ctx, "SQL select failed: Schema error 1015.");
    clog_failure(g_db_ctx, "Schema auth is corrupted, aborting.");
    
Radikant
File
Edit
View
Window
Help
network.log
01:09:03 [INFO] Interface initialization complete. 01:09:03 [WARN] High latency detected on port 8080. 01:09:03 [FAILURE] High cpu usage detected on remote 2 01:09:03 [ERROR] Connection 2 is lost
Radikant
File
Edit
View
Window
Help
database.log
01:08:57 [INFO] Transaction started for user ID 10. 01:08:57 [ERROR] SQL insert failed: Duplicate key. 01:08:57 [ERROR] SQL select failed: Schema error 1015. 01:08:57 [FAILURE] Schema auth is corrupted, aborting.