From 83fca91772244b46dc931355a9407f414eb3e06d Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 9 Oct 2026 21:13:29 +0000 Subject: [PATCH] fix(runtime): log to standard error, without colours when piped weft-runtime and weft-app-shell logged to standard output, which carries their readiness line to weft-appd. weft-appd keeps that stream only at debug level, so the runtime's warnings and errors, such as a failed grant or an ended IPC connection, never reached its log, and the lines carried terminal colour codes. Both now log to standard error, which weft-appd records at info level, with colours only on a terminal. In the nested desktop Counter check, the runtime's own lines appear in weft-appd's log; the grants check reads the hangup message from standard error. --- crates/weft-app-shell/src/main.rs | 4 ++++ crates/weft-runtime/src/main.rs | 4 ++++ tests/runtime/check_grants.py | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/weft-app-shell/src/main.rs b/crates/weft-app-shell/src/main.rs index 3b68c29..4bed9ee 100644 --- a/crates/weft-app-shell/src/main.rs +++ b/crates/weft-app-shell/src/main.rs @@ -11,7 +11,11 @@ mod keyutils; use anyhow::Context; fn main() -> anyhow::Result<()> { + // Standard output carries the readiness line to weft-appd, which keeps + // standard error as the process's log. tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_ansi(std::io::IsTerminal::is_terminal(&std::io::stderr())) .with_env_filter( tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), diff --git a/crates/weft-runtime/src/main.rs b/crates/weft-runtime/src/main.rs index d5b5097..b94f5a4 100644 --- a/crates/weft-runtime/src/main.rs +++ b/crates/weft-runtime/src/main.rs @@ -14,7 +14,11 @@ const DEFAULT_MAX_MEMORY_MIB: usize = 256; use grants::{Grants, Preopen}; fn main() -> anyhow::Result<()> { + // Standard output carries the readiness line to weft-appd, which keeps + // standard error as the process's log. tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_ansi(std::io::IsTerminal::is_terminal(&std::io::stderr())) .with_env_filter( tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), diff --git a/tests/runtime/check_grants.py b/tests/runtime/check_grants.py index fcee9a3..34ca8b7 100644 --- a/tests/runtime/check_grants.py +++ b/tests/runtime/check_grants.py @@ -207,8 +207,9 @@ def check_hangup(runtime, work): process.wait(timeout=10) except subprocess.TimeoutExpired: raise AssertionError("the runtime kept running after its IPC connection closed") - output = process.stdout.read() + process.stderr.read() - if process.returncode != 0 or "IPC connection ended" not in output: + log = process.stderr.read() + process.stdout.read() + if process.returncode != 0 or "IPC connection ended" not in log: raise AssertionError(f"the runtime did not end with the connection: " f"exit {process.returncode}") finally: