loggingrustraylib

Disable Raylib Iog messages


Is there a way to disable the output of Raylib? I'd like to not have this spammed in my terminal:

INFO: Initializing raylib 3.7
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Render size:  1024 x 768
INFO:     > Screen size:  1024 x 768
INFO:     > Viewport offsets: 0, 0
INFO: TEXTURE: [ID 1] Unloaded texture data from VRAM (GPU)
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: TEXTURE: [ID etc...] Unloaded texture data from VRAM (GPU)

There's more of these, this is just a portion of them


Solution

  • Rust Solution 1: You can call

    set_trace_log(TraceLogLevel::LOG_ERROR)
    

    to set a higher log level, as mentioned in the docs here.

    C Solution 1: Set a higher log level

    SetTraceLogLevel(LOG_ERROR); 
    

    possible values are:

    LOG_ALL: 0
    LOG_TRACE: 1
    LOG_DEBUG: 2
    LOG_INFO: 3
    LOG_WARNING: 4
    LOG_ERROR: 5
    LOG_FATAL: 6
    LOG_NONE: 7
    

    C Solution 2: Use custom callback function

    Another way can be seen in this example examples/core/core_custom_logging.c

    you should be able to register a callback function for handling log messages

    SetTraceLogCallback(CustomLog); // call this before InitWindow() 
    
    InitWindow(screenWidth, screenHeight, "titel");
    

    To receive no log prints whatsoever, the function can be as simple as:

    void CustomLog(int msgType, const char *text, va_list args)
    { 
      return;
    }