Skip to content

Commit 1ff160a

Browse files
authored
Optionally disable test tracing colors (#2374)
* Optionally disable test tracing colors * Fix lint
1 parent c677510 commit 1ff160a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sdk/core/azure_core_test/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ For example, if you wanted to see debug information from all sources by default
125125
RUST_LOG=debug,test-proxy=trace cargo test
126126
```
127127

128+
ANSI colors are written to the terminal even if redirected to a file. To disable writing ANSI color sequences, pass `NO_COLOR=1`:
129+
130+
```bash
131+
NO_COLOR=1 RUST_LOG=debug,test-proxy=trace cargo test
132+
```
133+
128134
[PowerShell]: https://learn.microsoft.com/powershell/scripting/install/installing-powershell
129135
[Test Proxy]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
130136
[Test Resources]: https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/TestResources/README.md

sdk/core/azure_core_test/src/recorded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ fn init_tracing() {
8989
tracing_subscriber::fmt()
9090
.with_env_filter(EnvFilter::from_default_env())
9191
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
92+
.with_ansi(std::env::var("NO_COLOR").map_or(true, |v| v.is_empty()))
9293
.with_writer(std::io::stderr)
9394
.init();
9495
}

0 commit comments

Comments
 (0)