raylib-rs / raylib-rs

Rust bindings for raylib
Other
49 stars 29 forks source link

Setting log level does nothing #27

Closed Sergiovan closed 6 months ago

Sergiovan commented 6 months ago

Problem

Description: Setting the log level via the RaylibBuilder or the RaylibHandle does not seem to work. Log messages from lower log levels still appear on the console.

Commit: 5.0.0

OS: Linux 6.6.10-1-MANJARO #⁠1 SMP PREEMPT_DYNAMIC Fri Jan 5 17:38:36 UTC 2024

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

cargo version: cargo 1.76.0 (c84b36747 2024-01-18)

Minimal example

Code

Cargo.toml

[package]
name = "raylib_logging"
version = "0.1.0"
edition = "2021"

[dependencies.raylib]
version = "5.0.0"
git = "https://github.com/raylib-rs/raylib-rs"
branch = "5.0.0"

[dependencies.raylib-sys]
version = "5.0.0"
git = "https://github.com/raylib-rs/raylib-rs"
branch = "5.0.0"

src/main.rs

use raylib::prelude::*;

fn main() {
    let (mut rl, thread) = raylib::init().log_level(TraceLogLevel::LOG_WARNING).build();
}

Expected behaviour

Program closes immediately. Nothing shows up on console.

Actual behavior.

The following shows up on console:

INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 2560 x 1440
INFO:     > Screen size:  640 x 480
INFO:     > Render size:  640 x 480
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 389
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce GTX 1080 Ti/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 545.29.06
INFO:     > GLSL:     3.30 NVIDIA via Cg compiler
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)

The program closes after that.

Extra info

I also tried building a window with title and size, and different logging levels. Still shows output. Even with level set to LOG_NONE it shows output.

I found this after upgrading from 4.5.0 (where setting the log level does work) to 5.0.0

IoIxD commented 6 months ago

Working as intended; we were setting the log level after initializing Raylib, which is important since Raylib itself starts logging when being initialized. A minimum reproducable example would not account for this.

But I will change this to reduce user confusion, since it's likely expected to work as it would have previously.