raylib/core/
logging.rs

1///! Functions to change the behavior of raylib logging.
2// TODO: refactor this entire thing to use log
3use crate::consts::TraceLogLevel;
4use crate::{ffi, RaylibHandle};
5use std::ffi::CString;
6
7impl RaylibHandle {
8    /// Set the current threshold (minimum) log level
9    #[inline]
10    pub fn set_trace_log(&self, types: TraceLogLevel) {
11        unsafe {
12            ffi::SetTraceLogLevel((types as u32) as i32);
13        }
14    }
15
16    /// Writes a trace log message (`Log::INFO`, `Log::WARNING`, `Log::ERROR`, `Log::DEBUG`).
17    #[inline]
18    pub fn trace_log(&self, msg_type: TraceLogLevel, text: &str) {
19        unsafe {
20            let text = CString::new(text).unwrap();
21            ffi::TraceLog((msg_type as u32) as i32, text.as_ptr());
22        }
23    }
24}