From 3f462e3eb7a26941de28ce8ef47cc425f81af259 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 3 Mar 2023 19:34:41 +0100 Subject: [PATCH] tracing: Use don't log on hot paths without trace-level --- Cargo.toml | 2 +- src/backend/kms/mod.rs | 6 +++--- src/logger/mod.rs | 4 ++-- src/shell/focus/mod.rs | 10 +++++----- src/shell/layout/tiling/mod.rs | 6 +++--- src/wayland/handlers/xdg_shell/popup.rs | 8 ++++---- src/xwayland.rs | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8939cd4e..17a3ac6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ ordered-float = "3.0" glow = "0.11.2" tracing-subscriber = { version = "0.3.16", features = ["env-filter", "tracing-log"] } tracing-journald = "0.3.0" -tracing = "0.1.37" +tracing = { version = "0.1.37", features = ["max_level_debug", "release_max_level_info"] } [dependencies.smithay] version = "0.3" diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 62c0b665..eeabd52c 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -57,7 +57,7 @@ use smithay::{ }, xwayland::XWaylandClientData, }; -use tracing::{debug, error, info, warn}; +use tracing::{error, info, trace, warn}; use std::{ cell::RefCell, @@ -200,7 +200,7 @@ pub fn init_backend( .with_context(|| format!("Failed to remove drm device: {}", device_id)), } { Ok(()) => { - debug!("Successfully handled udev event.") + trace!("Successfully handled udev event.") } Err(err) => { error!(?err, "Error while handling udev event.") @@ -1133,7 +1133,7 @@ impl KmsState { render, surface, ) { - debug!(?err, "Early import failed."); + trace!(?err, "Early import failed."); } } diff --git a/src/logger/mod.rs b/src/logger/mod.rs index f0c071a0..6b697755 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -17,9 +17,9 @@ pub fn init_logger() -> Result<()> { let filter = EnvFilter::try_from_default_env() .unwrap_or_else(|_| { EnvFilter::new(if cfg!(debug_assertions) { - "warn" + "info" } else { - "error" + "warn" }) }) .add_directive(Directive::from_str("cosmic_text=error").unwrap()) diff --git a/src/shell/focus/mod.rs b/src/shell/focus/mod.rs index eb5c0774..52c632ed 100644 --- a/src/shell/focus/mod.rs +++ b/src/shell/focus/mod.rs @@ -12,7 +12,7 @@ use smithay::{ utils::{IsAlive, Serial, SERIAL_COUNTER}, }; use std::cell::RefCell; -use tracing::{debug, info}; +use tracing::{debug, trace}; use self::target::{KeyboardFocusTarget, WindowGroup}; @@ -101,7 +101,7 @@ impl Shell { if let Some(workspace) = state.common.shell.space_for_mut(mapped) { let mut focus_stack = workspace.focus_stack.get_mut(active_seat); if Some(mapped) != focus_stack.last() { - debug!(?mapped, "Focusing window."); + trace!(?mapped, "Focusing window."); focus_stack.append(mapped); // also remove popup grabs, if we are switching focus if let Some(mut popup_grab) = active_seat @@ -203,7 +203,7 @@ impl Common { { continue; // Focus is valid } else { - debug!("Wrong Window, focus fixup"); + trace!("Wrong Window, focus fixup"); } } KeyboardFocusTarget::LayerSurface(layer) => { @@ -224,7 +224,7 @@ impl Common { } // Focus is valid }; } else { - debug!("Surface dead, focus fixup"); + trace!("Surface dead, focus fixup"); } } else { continue; @@ -263,7 +263,7 @@ impl Common { .map(KeyboardFocusTarget::from) }); if let Some(keyboard) = seat.get_keyboard() { - info!("Restoring focus to {:?}", target.as_ref()); + debug!("Restoring focus to {:?}", target.as_ref()); keyboard.set_focus(state, target.clone(), SERIAL_COUNTER.next_serial()); ActiveFocus::set(&seat, target); } diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 187c33a7..0f357287 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -31,7 +31,7 @@ use smithay::{ wayland::seat::WaylandFocus, }; use std::{borrow::Borrow, collections::HashMap, hash::Hash, sync::Arc}; -use tracing::debug; +use tracing::trace; mod grabs; pub use self::grabs::*; @@ -421,7 +421,7 @@ impl TilingLayout { }); // remove self - debug!(?mapped, "Remove window."); + trace!(?mapped, "Remove window."); let _ = tree.remove_node(node_id.clone(), RemoveBehavior::DropChildren); // fixup parent node @@ -434,7 +434,7 @@ impl TilingLayout { if group.len() > 2 { group.remove_window(position); } else { - debug!("Removing Group"); + trace!("Removing Group"); let other_child = tree.children_ids(&id).unwrap().cloned().next().unwrap(); let fork_pos = parent_parent_id.as_ref().and_then(|parent_id| { diff --git a/src/wayland/handlers/xdg_shell/popup.rs b/src/wayland/handlers/xdg_shell/popup.rs index 2d50b5d3..e91f7e0a 100644 --- a/src/wayland/handlers/xdg_shell/popup.rs +++ b/src/wayland/handlers/xdg_shell/popup.rs @@ -24,7 +24,7 @@ use smithay::{ }, }; use std::sync::Mutex; -use tracing::{debug, warn}; +use tracing::{trace, warn}; impl Shell { pub fn unconstrain_popup(&self, surface: &PopupSurface, positioner: &PositionerState) { @@ -104,7 +104,7 @@ fn unconstrain_xdg_popup_tile(surface: &PopupSurface, rect: Rectangle, @@ -489,7 +489,7 @@ impl XwmHandler for Data { } fn new_selection(&mut self, xwm: XwmId, selection: SelectionType, mime_types: Vec) { - info!(?selection, ?mime_types, "Got Selection from Xwayland",); + trace!(?selection, ?mime_types, "Got Selection from Xwayland",); if self.state.common.is_x_focused(xwm) { let seat = self.state.common.last_active_seat();