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.
This commit is contained in:
Marco Allegretti 2026-10-09 21:13:29 +00:00
parent 57f364890f
commit 83fca91772
No known key found for this signature in database
3 changed files with 11 additions and 2 deletions

View file

@ -11,7 +11,11 @@ mod keyutils;
use anyhow::Context; use anyhow::Context;
fn main() -> anyhow::Result<()> { 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() tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_ansi(std::io::IsTerminal::is_terminal(&std::io::stderr()))
.with_env_filter( .with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env() tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),

View file

@ -14,7 +14,11 @@ const DEFAULT_MAX_MEMORY_MIB: usize = 256;
use grants::{Grants, Preopen}; use grants::{Grants, Preopen};
fn main() -> anyhow::Result<()> { 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() tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_ansi(std::io::IsTerminal::is_terminal(&std::io::stderr()))
.with_env_filter( .with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env() tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),

View file

@ -207,8 +207,9 @@ def check_hangup(runtime, work):
process.wait(timeout=10) process.wait(timeout=10)
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
raise AssertionError("the runtime kept running after its IPC connection closed") raise AssertionError("the runtime kept running after its IPC connection closed")
output = process.stdout.read() + process.stderr.read() log = process.stderr.read()
if process.returncode != 0 or "IPC connection ended" not in output: 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: " raise AssertionError(f"the runtime did not end with the connection: "
f"exit {process.returncode}") f"exit {process.returncode}")
finally: finally: