Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When ANSI is enabled, nu_ansi_term::enable_ansi_support() should be called on Windows #3068

Open
czy-29 opened this issue Aug 28, 2024 · 2 comments · May be fixed by #3079
Open

When ANSI is enabled, nu_ansi_term::enable_ansi_support() should be called on Windows #3068

czy-29 opened this issue Aug 28, 2024 · 2 comments · May be fixed by #3079

Comments

@czy-29
Copy link

czy-29 commented Aug 28, 2024

Bug Report

Version

tracing-subscriber: v0.3.18

Platform

64-bit (Windows)

Crates

tracing-subscriber

Description

When ANSI is enabled, nu_ansi_term::enable_ansi_support() should be called on Windows, otherwise the ANSI color will appear as garbled (as it is now).

I know users can manually call this to solve the problem, but I believe that tracing-subscriber should provide an out-of-the-box solution for this, and the call should be transparent to users. Therefore, I think this is a bug that needs to be fixed.

czy-29 added a commit to opensound-org/gitops-cli that referenced this issue Aug 28, 2024
@kaffarell
Copy link
Contributor

I think this is fine, the problem is just where to put it... We can't put it in the (fmt) Subscriber::with_ansi function, because that's not the only place we set the ansi attribute. We would need to add this everywhere.

@czy-29
Copy link
Author

czy-29 commented Sep 9, 2024

I think this is fine, the problem is just where to put it... We can't put it in the (fmt) Subscriber::with_ansi function, because that's not the only place we set the ansi attribute. We would need to add this everywhere.

Yes, when I wrote this issue, I originally intended to submit a PR directly, but later I realized it wasn't that simple... The key issue is, as you said, where should we put it... However, no matter how it is implemented, I believe this logic should indeed be part of the fmt implementation.

kaffarell added a commit to kaffarell/tracing that referenced this issue Sep 10, 2024
To correctly enable the ansi output, we need to call
`nu_ansi_term::enable_ansi_support` on windows before outputting ansi
characters.

Fixes: tokio-rs#3068
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 a pull request may close this issue.

2 participants