Skip to main content

strip_ansi

Function strip_ansi 

Source
fn strip_ansi(input: &str) -> String
Expand description

Strip ANSI/CSI escape sequences (\x1b[...<letter>) from soma serve’s captured subprocess log before substring-matching it.

tracing_subscriber::fmt() defaults to ANSI-colorized output unless .with_ansi(false) is explicitly set (see apps/soma/src/bootstrap.rs::init_logging) — confirmed empirically that this holds even when stdout/stderr are redirected to a plain file, not just a real terminal. The in-process tracing captures in apps/soma/tests/mcp_trace_headers.rs sidestep this by building their own subscriber with .with_ansi(false), but this smoke spawns a real soma subprocess and can only observe its already-formatted stdout/stderr text, so color codes land inside field name/value boundaries (e.g. trace_id_prefix <ESC>[0m<ESC>[2m = <ESC>[0m Some(...)) and silently break a naive contains(...) check — every “logs contain X” assertion failed until this was added, even though the underlying trace data was correct (verified by hand against the raw captured log).