Skip to content

Conversation

@rockygeekz
Copy link

@rockygeekz rockygeekz commented Dec 26, 2025

Summary

This PR disables ANSI color output when cargo-wdk stderr is not a TTY.

When output is redirected to a file, ANSI escape sequences may currently be
emitted, resulting in unreadable logs. This change detects non-TTY output
and disables colorized logging, producing clean and readable text output
when redirected.

Details

  • Detects whether stderr is a terminal using std::io::IsTerminal
  • Preserves colored output for interactive terminals
  • Disables ANSI formatting when output is redirected to files or pipes
  • No behavioral changes to logging levels or CLI functionality

Rationale

ANSI escape sequences are intended for interactive terminals only.
Disabling them for non-TTY output aligns cargo-wdk with standard CLI
behavior (e.g. cargo, git, ripgrep).

Notes

  • This change only affects log presentation
  • No tests were added as this behavior is environment-dependent and
    init_tracing currently has no test coverage

Fixes #600

@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.67%. Comparing base (c3c1223) to head (97254ad).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #601   +/-   ##
=======================================
  Coverage   82.66%   82.67%           
=======================================
  Files          25       25           
  Lines        7137     7138    +1     
  Branches     7137     7138    +1     
=======================================
+ Hits         5900     5901    +1     
  Misses       1108     1108           
  Partials      129      129           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rockygeekz
Copy link
Author

Updated, thanks!

@gurry gurry enabled auto-merge December 29, 2025 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo-wdk emits ANSI escape sequences when redirected to file

3 participants