patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH 2/2] tools/xdg-desktop-portal-spectrum-host: use tracing
Date: Thu, 26 Feb 2026 16:07:32 +0100	[thread overview]
Message-ID: <20260226150732.150645-2-hi@alyssa.is> (raw)
In-Reply-To: <20260226150732.150645-1-hi@alyssa.is>

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);
     }
 }
-- 
2.52.0


  reply	other threads:[~2026-02-26 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 15:07 [PATCH 1/2] tools/xdg-desktop-portal-spectrum-host: set up log Alyssa Ross
2026-02-26 15:07 ` Alyssa Ross [this message]
2026-02-26 18:54   ` [PATCH 2/2] tools/xdg-desktop-portal-spectrum-host: use tracing Demi Marie Obenour
2026-02-27 11:08   ` Alyssa Ross
2026-02-27 11:08 ` [PATCH 1/2] tools/xdg-desktop-portal-spectrum-host: set up log Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260226150732.150645-2-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).