1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Use tracing crate for logging (#1192)

* egui_web: use tracing crate
* egui_glow: use tracing crate
* Log at the debug level
* egui_demo_app: enable tracing to log to stdout
* Use tracing in egui-winit
* Add opt-in tracing support to egui
This commit is contained in:
Emil Ernerfeldt
2022-02-01 12:27:39 +01:00
committed by GitHub
parent 1f03f53dc0
commit c6ac1827f6
28 changed files with 194 additions and 107 deletions

View File

@@ -5,29 +5,15 @@ use std::option::Option::Some;
pub fn check_for_gl_error(gl: &glow::Context, context: &str) {
let error_code = unsafe { gl.get_error() };
if error_code != glow::NO_ERROR {
glow_print_error(format!(
tracing::error!(
"GL error, at: '{}', code: {} (0x{:X})",
context, error_code, error_code
));
context,
error_code,
error_code
);
}
}
pub(crate) fn glow_print(s: impl std::fmt::Display) {
#[cfg(target_arch = "wasm32")]
web_sys::console::log_1(&format!("egui_glow: {}", s).into());
#[cfg(not(target_arch = "wasm32"))]
eprintln!("egui_glow: {}", s);
}
pub(crate) fn glow_print_error(s: impl std::fmt::Display) {
#[cfg(target_arch = "wasm32")]
web_sys::console::error_1(&format!("egui_glow: {}", s).into());
#[cfg(not(target_arch = "wasm32"))]
eprintln!("egui_glow ERROR: {}", s);
}
pub(crate) unsafe fn compile_shader(
gl: &glow::Context,
shader_type: u32,
@@ -130,7 +116,7 @@ pub(crate) fn supports_vao(gl: &glow::Context) -> bool {
const OPENGL_ES_PREFIX: &str = "OpenGL ES ";
let version_string = unsafe { gl.get_parameter_string(glow::VERSION) };
glow_print(format!("GL version: {:?}.", version_string));
tracing::debug!("GL version: {:?}.", version_string);
// Examples:
// * "WebGL 2.0 (OpenGL ES 3.0 Chromium)"