Skip to content

Logging System

GAMINGNOOBdev edited this page Sep 1, 2025 · 1 revision

To use the embedded logging system you have to link to baranium. The actual usage is quite simple.

Initialization

Usually you can use the logging system even without initialization but you can initialize some extra parameters.

#include <baranium/logging.h>

int main()
{
    log_enable_debug_msgs(1); // completely removes debug messages
    log_enable_stdout(1); // as the name says, enable/disable logging to stdout

    FILE* file = fopen("log.txt", "wb+");
    log_set_stream(file); // set the output stream of the logs, can be stderr or stdout too, messages will be fflushed immediately to ensure accuracy

    /// at the end of your program
    fclose(file); // do NOT use any log functions afterwards

    // ...
}

Logging

Logging itself works like using printf, with each log level being a different "function"/macro.

Function Description
LOGINFO Log info messages
LOGDEBUG Log debug messages
LOGERROR Log error messages
LOGWARNING Log warning messages

Usage examples:

int value = 10;
LOGDEBUG("my very important value: %d", value);
LOGINFO("imporant info: logging enabled.");
LOGWARNING("cant find files in '%s', check installation", current_working_path);
LOGERROR("unable to find files to launch");

Clone this wiki locally