mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -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:
@@ -50,8 +50,8 @@ egui = { version = "0.21.0", path = "../egui", default-features = false, feature
|
||||
|
||||
bytemuck = "1.7"
|
||||
glow = "0.12"
|
||||
log = { version = "0.4", features = ["std"] }
|
||||
memoffset = "0.6"
|
||||
tracing = { version = "0.1", default-features = false, features = ["std"] }
|
||||
|
||||
#! ### Optional dependencies
|
||||
## Enable this when generating docs.
|
||||
|
||||
@@ -39,7 +39,7 @@ impl GlutinWindowContext {
|
||||
.with_stencil_size(0)
|
||||
.with_transparency(false);
|
||||
|
||||
tracing::debug!("trying to get gl_config");
|
||||
log::debug!("trying to get gl_config");
|
||||
let (mut window, gl_config) =
|
||||
glutin_winit::DisplayBuilder::new() // let glutin-winit helper crate handle the complex parts of opengl context creation
|
||||
.with_preference(glutin_winit::ApiPrefence::FallbackEgl) // https://github.com/emilk/egui/issues/2520#issuecomment-1367841150
|
||||
@@ -55,10 +55,10 @@ impl GlutinWindowContext {
|
||||
)
|
||||
.expect("failed to create gl_config");
|
||||
let gl_display = gl_config.display();
|
||||
tracing::debug!("found gl_config: {:?}", &gl_config);
|
||||
log::debug!("found gl_config: {:?}", &gl_config);
|
||||
|
||||
let raw_window_handle = window.as_ref().map(|w| w.raw_window_handle());
|
||||
tracing::debug!("raw window handle: {:?}", raw_window_handle);
|
||||
log::debug!("raw window handle: {:?}", raw_window_handle);
|
||||
let context_attributes =
|
||||
glutin::context::ContextAttributesBuilder::new().build(raw_window_handle);
|
||||
// by default, glutin will try to create a core opengl context. but, if it is not available, try to create a gl-es context using this fallback attributes
|
||||
@@ -69,7 +69,7 @@ impl GlutinWindowContext {
|
||||
gl_display
|
||||
.create_context(&gl_config, &context_attributes)
|
||||
.unwrap_or_else(|_| {
|
||||
tracing::debug!("failed to create gl_context with attributes: {:?}. retrying with fallback context attributes: {:?}",
|
||||
log::debug!("failed to create gl_context with attributes: {:?}. retrying with fallback context attributes: {:?}",
|
||||
&context_attributes,
|
||||
&fallback_context_attributes);
|
||||
gl_config
|
||||
@@ -81,7 +81,7 @@ impl GlutinWindowContext {
|
||||
|
||||
// this is where the window is created, if it has not been created while searching for suitable gl_config
|
||||
let window = window.take().unwrap_or_else(|| {
|
||||
tracing::debug!("window doesn't exist yet. creating one now with finalize_window");
|
||||
log::debug!("window doesn't exist yet. creating one now with finalize_window");
|
||||
glutin_winit::finalize_window(event_loop, winit_window_builder.clone(), &gl_config)
|
||||
.expect("failed to finalize glutin window")
|
||||
});
|
||||
@@ -91,7 +91,7 @@ impl GlutinWindowContext {
|
||||
let surface_attributes =
|
||||
glutin::surface::SurfaceAttributesBuilder::<glutin::surface::WindowSurface>::new()
|
||||
.build(window.raw_window_handle(), width, height);
|
||||
tracing::debug!(
|
||||
log::debug!(
|
||||
"creating surface with attributes: {:?}",
|
||||
&surface_attributes
|
||||
);
|
||||
@@ -100,7 +100,7 @@ impl GlutinWindowContext {
|
||||
.create_window_surface(&gl_config, &surface_attributes)
|
||||
.unwrap()
|
||||
};
|
||||
tracing::debug!("surface created successfully: {gl_surface:?}.making context current");
|
||||
log::debug!("surface created successfully: {gl_surface:?}.making context current");
|
||||
let gl_context = not_current_gl_context.make_current(&gl_surface).unwrap();
|
||||
|
||||
gl_surface
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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!"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user