From 8b8098bc7e033bd38857a4f7d4b2124972f9283d Mon Sep 17 00:00:00 2001 From: Nathan Moos Date: Thu, 28 Mar 2024 23:43:38 -0700 Subject: [PATCH] migrate println statements to DEBUG-level logging (#64) --- Cargo.toml | 1 + src/context.rs | 8 ++++---- src/winit_event_loop.rs | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cd4ea0b..272a8ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ vger = "0.2.8" accesskit = "0.11.0" lazy_static = "1.4.0" winit = { version = "0.28.1", optional = true } +log = "0.4" # Seems we can't publish to crates.io with this dependency. # baseview = { git = "https://github.com/RustAudio/baseview", optional = true } diff --git a/src/context.rs b/src/context.rs index 13b8c8c..d98bada 100644 --- a/src/context.rs +++ b/src/context.rs @@ -198,9 +198,9 @@ impl Context { assert_eq!(path.len(), 1); if nodes != *access_nodes { - println!("access nodes:"); + log::debug!("access nodes:"); for (id, node) in &nodes { - println!( + log::debug!( " id: {:?} role: {:?}, children: {:?}", id, node.role(), @@ -209,7 +209,7 @@ impl Context { } *access_nodes = nodes; } else { - // println!("access nodes unchanged"); + // log::debug!("access nodes unchanged"); } // XXX: we're doing layout both here and in rendering. @@ -330,7 +330,7 @@ impl Context { for action in actions { if !action.is::<()>() { - println!("unhandled action: {:?}", action.type_id()); + log::debug!("unhandled action: {:?}", action.type_id()); } } } diff --git a/src/winit_event_loop.rs b/src/winit_event_loop.rs index f637005..0360711 100644 --- a/src/winit_event_loop.rs +++ b/src/winit_event_loop.rs @@ -34,7 +34,7 @@ pub fn on_main(f: impl FnOnce(&mut Context) + Send + 'static) { let opt_proxy = GLOBAL_EVENT_LOOP_PROXY.lock().unwrap(); if let Some(proxy) = &*opt_proxy { if let Err(err) = proxy.send_event(()) { - println!("error waking up event loop: {:?}", err); + log::debug!("error waking up event loop: {:?}", err); } } } @@ -86,7 +86,7 @@ async fn setup(window: &Window) -> Setup { #[cfg(not(target_arch = "wasm32"))] { let adapter_info = adapter.get_info(); - println!("Using {} ({:?})", adapter_info.name, adapter_info.backend); + log::debug!("Using {} ({:?})", adapter_info.name, adapter_info.backend); } let trace_dir = std::env::var("WGPU_TRACE"); @@ -115,7 +115,7 @@ fn process_event(cx: &mut Context, view: &impl View, event: &Event, window: &Win cx.process(view, event); if cx.grab_cursor && !cx.prev_grab_cursor { - println!("grabbing cursor"); + log::debug!("grabbing cursor"); window .set_cursor_grab(winit::window::CursorGrabMode::Locked) .or_else(|_e| window.set_cursor_grab(winit::window::CursorGrabMode::Confined)) @@ -124,7 +124,7 @@ fn process_event(cx: &mut Context, view: &impl View, event: &Event, window: &Win } if !cx.grab_cursor && cx.prev_grab_cursor { - println!("releasing cursor"); + log::debug!("releasing cursor"); window .set_cursor_grab(winit::window::CursorGrabMode::None) .unwrap(); @@ -195,7 +195,7 @@ pub fn rui(view: impl View) { event: WindowEvent::CloseRequested, .. } => { - println!("The close button was pressed; stopping"); + log::debug!("The close button was pressed; stopping"); *control_flow = ControlFlow::Exit } WEvent::WindowEvent { @@ -207,14 +207,14 @@ pub fn rui(view: impl View) { }, .. } => { - // println!("Resizing to {:?}", size); + // log::debug!("Resizing to {:?}", size); config.width = size.width.max(1); config.height = size.height.max(1); surface.configure(&device, &config); window.request_redraw(); } WEvent::UserEvent(_) => { - // println!("received user event"); + // log::debug!("received user event"); // Process the work queue. #[cfg(not(target_arch = "wasm32"))] @@ -235,7 +235,7 @@ pub fn rui(view: impl View) { let window_size = window.inner_size(); let scale = window.scale_factor() as f32; - // println!("window_size: {:?}", window_size); + // log::debug!("window_size: {:?}", window_size); let width = window_size.width as f32 / scale; let height = window_size.height as f32 / scale; @@ -257,11 +257,11 @@ pub fn rui(view: impl View) { let window_size = window.inner_size(); let scale = window.scale_factor() as f32; - // println!("window_size: {:?}", window_size); + // log::debug!("window_size: {:?}", window_size); let width = window_size.width as f32 / scale; let height = window_size.height as f32 / scale; - // println!("RedrawRequested"); + // log::debug!("RedrawRequested"); cx.render( RenderInfo { device: &device,