1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Replace tracing with log (#2928)

* Replace tracing crate with log

It's just so much simpler to use

* Add `bacon wasm` job

* eframe: add a WebLogger for piping log events to the web console
This commit is contained in:
Emil Ernerfeldt
2023-04-18 21:11:26 +02:00
committed by GitHub
parent 0f9e1a3526
commit 9c9a54ce36
48 changed files with 477 additions and 291 deletions

View File

@@ -25,7 +25,7 @@ pub mod winit;
#[cfg(all(not(target_arch = "wasm32"), feature = "winit"))]
pub use winit::*;
/// Check for OpenGL error and report it using `tracing::error`.
/// Check for OpenGL error and report it using `log::error`.
///
/// Only active in debug builds!
///
@@ -49,7 +49,7 @@ macro_rules! check_for_gl_error {
}};
}
/// Check for OpenGL error and report it using `tracing::error`.
/// Check for OpenGL error and report it using `log::error`.
///
/// WARNING: slow! Only use during setup!
///
@@ -90,7 +90,7 @@ pub fn check_for_gl_error_impl(gl: &glow::Context, file: &str, line: u32, contex
};
if context.is_empty() {
tracing::error!(
log::error!(
"GL error, at {}:{}: {} (0x{:X}). Please file a bug at https://github.com/emilk/egui/issues",
file,
line,
@@ -98,7 +98,7 @@ pub fn check_for_gl_error_impl(gl: &glow::Context, file: &str, line: u32, contex
error_code,
);
} else {
tracing::error!(
log::error!(
"GL error, at {}:{} ({}): {} (0x{:X}). Please file a bug at https://github.com/emilk/egui/issues",
file,
line,

View File

@@ -111,7 +111,7 @@ impl Painter {
let version = gl.get_parameter_string(glow::VERSION);
let renderer = gl.get_parameter_string(glow::RENDERER);
let vendor = gl.get_parameter_string(glow::VENDOR);
tracing::debug!(
log::debug!(
"\nopengl version: {version}\nopengl renderer: {renderer}\nopengl vendor: {vendor}"
);
}
@@ -127,16 +127,16 @@ impl Painter {
let shader_version = shader_version.unwrap_or_else(|| ShaderVersion::get(&gl));
let is_webgl_1 = shader_version == ShaderVersion::Es100;
let shader_version_declaration = shader_version.version_declaration();
tracing::debug!("Shader header: {:?}.", shader_version_declaration);
log::debug!("Shader header: {:?}.", shader_version_declaration);
let supported_extensions = gl.supported_extensions();
tracing::trace!("OpenGL extensions: {supported_extensions:?}");
log::trace!("OpenGL extensions: {supported_extensions:?}");
let srgb_textures = shader_version == ShaderVersion::Es300 // WebGL2 always support sRGB
|| supported_extensions.iter().any(|extension| {
// EXT_sRGB, GL_ARB_framebuffer_sRGB, GL_EXT_sRGB, GL_EXT_texture_sRGB_decode, …
extension.contains("sRGB")
});
tracing::debug!("SRGB texture Support: {:?}", srgb_textures);
log::debug!("SRGB texture Support: {:?}", srgb_textures);
unsafe {
let vert = compile_shader(
@@ -399,7 +399,7 @@ impl Painter {
if let Some(callback) = callback.callback.downcast_ref::<CallbackFn>() {
(callback.f)(info, self);
} else {
tracing::warn!("Warning: Unsupported render callback. Expected egui_glow::CallbackFn");
log::warn!("Warning: Unsupported render callback. Expected egui_glow::CallbackFn");
}
check_for_gl_error!(&self.gl, "callback");
@@ -455,7 +455,7 @@ impl Painter {
check_for_gl_error!(&self.gl, "paint_mesh");
} else {
tracing::warn!("Failed to find texture {:?}", mesh.texture_id);
log::warn!("Failed to find texture {:?}", mesh.texture_id);
}
}
@@ -713,7 +713,7 @@ pub fn clear(gl: &glow::Context, screen_size_in_pixels: [u32; 2], clear_color: [
impl Drop for Painter {
fn drop(&mut self) {
if !self.destroyed {
tracing::warn!(
log::warn!(
"You forgot to call destroy() on the egui glow painter. Resources will leak!"
);
}

View File

@@ -24,7 +24,7 @@ impl ShaderVersion {
let shading_lang_string =
unsafe { gl.get_parameter_string(glow::SHADING_LANGUAGE_VERSION) };
let shader_version = Self::parse(&shading_lang_string);
tracing::debug!(
log::debug!(
"Shader version: {:?} ({:?}).",
shader_version,
shading_lang_string

View File

@@ -59,7 +59,7 @@ impl VertexArrayObject {
Some(vao)
} else {
tracing::debug!("VAO not supported");
log::debug!("VAO not supported");
None
};
@@ -113,7 +113,7 @@ fn supports_vao(gl: &glow::Context) -> bool {
const OPENGL_ES_PREFIX: &str = "OpenGL ES ";
let version_string = unsafe { gl.get_parameter_string(glow::VERSION) };
tracing::debug!("GL version: {:?}.", version_string);
log::debug!("GL version: {:?}.", version_string);
// Examples:
// * "WebGL 2.0 (OpenGL ES 3.0 Chromium)"
@@ -124,7 +124,7 @@ fn supports_vao(gl: &glow::Context) -> bool {
if version_str.contains("1.0") {
// need to test OES_vertex_array_object .
let supported_extensions = gl.supported_extensions();
tracing::debug!("Supported OpenGL extensions: {:?}", supported_extensions);
log::debug!("Supported OpenGL extensions: {:?}", supported_extensions);
supported_extensions.contains("OES_vertex_array_object")
|| supported_extensions.contains("GL_OES_vertex_array_object")
} else {
@@ -135,7 +135,7 @@ fn supports_vao(gl: &glow::Context) -> bool {
if version_string.contains("2.0") {
// need to test OES_vertex_array_object .
let supported_extensions = gl.supported_extensions();
tracing::debug!("Supported OpenGL extensions: {:?}", supported_extensions);
log::debug!("Supported OpenGL extensions: {:?}", supported_extensions);
supported_extensions.contains("OES_vertex_array_object")
|| supported_extensions.contains("GL_OES_vertex_array_object")
} else {
@@ -147,7 +147,7 @@ fn supports_vao(gl: &glow::Context) -> bool {
// I found APPLE_vertex_array_object , GL_ATI_vertex_array_object ,ARB_vertex_array_object
// but APPLE's and ATI's very old extension.
let supported_extensions = gl.supported_extensions();
tracing::debug!("Supported OpenGL extensions: {:?}", supported_extensions);
log::debug!("Supported OpenGL extensions: {:?}", supported_extensions);
supported_extensions.contains("ARB_vertex_array_object")
|| supported_extensions.contains("GL_ARB_vertex_array_object")
} else {

View File

@@ -22,7 +22,7 @@ impl EguiGlow {
) -> Self {
let painter = crate::Painter::new(gl, "", shader_version)
.map_err(|error| {
tracing::error!("error occurred in initializing painter:\n{}", error);
log::error!("error occurred in initializing painter:\n{}", error);
})
.unwrap();