From 53b6072bd995b5b4017999cf247f9eb6660c72a2 Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Sat, 1 Nov 2025 14:43:44 +0000 Subject: [PATCH] refactor: improve logs, unify integration log fmt The catch-all case of `handle_client_message` now logs the atom's name instead of its opaque atom id. `get_atom_name` now warns there was an error and returns a filler name. Since most the use of `get_atom_name` is in logging, this makes those logs easier to read. The integration tests now use `formatted_timed_builder` logger constructor, which should unify the look of logs between the integration tests and the main binary. --- src/xstate/mod.rs | 10 ++++++++-- tests/integration.rs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xstate/mod.rs b/src/xstate/mod.rs index 37c39e5..89af3bb 100644 --- a/src/xstate/mod.rs +++ b/src/xstate/mod.rs @@ -590,7 +590,10 @@ impl XState { } } } - t => warn!("unrecognized message: {t:?}"), + t => warn!( + "unrecognized message: {:?}", + get_atom_name(&self.connection, t) + ), } } @@ -1415,6 +1418,9 @@ impl XConnection for RealConnection { fn get_atom_name(connection: &xcb::Connection, atom: x::Atom) -> String { match connection.wait_for_reply(connection.send_request(&x::GetAtomName { atom })) { Ok(reply) => reply.name().to_string(), - Err(err) => format!(" {atom:?}"), + Err(err) => { + warn!(" {atom:?}"); + format!("ATOM_{}", atom.resource_id()) + } } } diff --git a/tests/integration.rs b/tests/integration.rs index 1fe3eaa..d1e0005 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -126,7 +126,7 @@ impl Fixture { fn new_preset(pre_connect: impl FnOnce(&mut testwl::Server)) -> Self { static INIT: Once = Once::new(); INIT.call_once(|| { - pretty_env_logger::env_logger::builder() + pretty_env_logger::formatted_timed_builder() .is_test(true) .filter_level(log::LevelFilter::Debug) .parse_default_env()