On 2/26/26 10:07, Alyssa Ross wrote:
Given we need this anyway for zbus, might as well use it.
Signed-off-by: Alyssa Ross <hi@alyssa.is> --- .../src/file_chooser.rs | 6 ++--- .../src/main.rs | 22 ++++++------------- 2 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/tools/xdg-desktop-portal-spectrum-host/src/file_chooser.rs b/tools/xdg-desktop-portal-spectrum-host/src/file_chooser.rs index 4eae5b9..17532db 100644 --- a/tools/xdg-desktop-portal-spectrum-host/src/file_chooser.rs +++ b/tools/xdg-desktop-portal-spectrum-host/src/file_chooser.rs @@ -8,12 +8,12 @@ use std::path::PathBuf; use std::sync::OnceLock;
use percent_encoding::percent_decode; +use tracing::error; use url::Url; use zbus::zvariant::{Array, ObjectPath, OwnedValue, Value}; use zbus::{Connection, interface};
use crate::documents::share_file; -use crate::msg;
const XDG_DESKTOP_PORTAL_RESPONSE_SUCCESS: u32 = 0; const XDG_DESKTOP_PORTAL_RESPONSE_CANCELLED: u32 = 1; @@ -50,7 +50,7 @@ impl FileChooser { Ok(Some(results)) => Ok((XDG_DESKTOP_PORTAL_RESPONSE_SUCCESS, results)), Ok(None) => Ok((XDG_DESKTOP_PORTAL_RESPONSE_CANCELLED, BTreeMap::new())), Err(e) => { - msg(&e); + error!("{e}"); Ok((XDG_DESKTOP_PORTAL_RESPONSE_OTHER, BTreeMap::new())) } } @@ -71,7 +71,7 @@ impl FileChooser { Ok(Some(results)) => Ok((XDG_DESKTOP_PORTAL_RESPONSE_SUCCESS, results)), Ok(None) => Ok((XDG_DESKTOP_PORTAL_RESPONSE_CANCELLED, BTreeMap::new())), Err(e) => { - msg(&e); + error!("{e}"); Ok((XDG_DESKTOP_PORTAL_RESPONSE_OTHER, BTreeMap::new())) } } diff --git a/tools/xdg-desktop-portal-spectrum-host/src/main.rs b/tools/xdg-desktop-portal-spectrum-host/src/main.rs index 40b14b4..f714aad 100644 --- a/tools/xdg-desktop-portal-spectrum-host/src/main.rs +++ b/tools/xdg-desktop-portal-spectrum-host/src/main.rs @@ -23,6 +23,7 @@ use landlock::{ ABI, Access, AccessFs, AccessNet, CompatLevel, Compatible, Ruleset, RulesetAttr, RulesetError, Scope, }; +use tracing::{error, info}; use tracing_subscriber::EnvFilter; use zbus::{AuthMechanism, Connection, MessageStream, connection};
@@ -158,7 +159,7 @@ async fn run_guest_connection(mut conn: Async<UnixStream>) -> Result<(), String> { let e = format!("sending setup response to guest: {e}"); if guest_dbus_conn_result.is_err() { - msg(&e); + error!("{e}"); } else { return Err(e); } @@ -167,7 +168,7 @@ async fn run_guest_connection(mut conn: Async<UnixStream>) -> Result<(), String> drop(conn); let guest_dbus_conn = guest_dbus_conn_result?;
- msg("Created org.freedesktop.impl.portal.desktop.spectrum.host on guest bus"); + info!("Created org.freedesktop.impl.portal.desktop.spectrum.host on guest bus");
let mut guest_messages = MessageStream::from(guest_dbus_conn); loop { @@ -229,7 +230,7 @@ fn read_argv() { args.next();
if args.next().is_some() { - msg("too many arguments"); + error!("too many arguments"); exit(1); } } @@ -258,7 +259,7 @@ fn run() -> Result<(), String> { let (conn, _) = match stdin.accept().await { Ok(conn) => conn, Err(e) => { - msg(&format!("accepting connection from guest: {e}")); + error!("accepting connection from guest: {e}"); continue; } }; @@ -275,7 +276,7 @@ fn run() -> Result<(), String> { EXECUTOR .spawn(async move { if let Err(e) = run_guest_connection(conn).await { - msg(&format!("guest connection error: {e}")); + error!("guest connection error: {e}"); } }) .detach(); @@ -283,18 +284,9 @@ fn run() -> Result<(), String> { })) }
-fn msg(e: &str) { - if let Some(prog) = args_os().next() - && let Some(prog) = PathBuf::from(prog).file_name() - { - eprint!("{}: ", prog.to_string_lossy()); - } - eprintln!("{e}"); -} - fn main() { if let Err(e) = run() { - msg(&e); + error!("{e}"); exit(1); } }
Acked-by: Demi Marie Obenour <demiobenour@gmail.com> -- Sincerely, Demi Marie Obenour (she/her/hers)