tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.52k stars 725 forks source link

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

Open czy-29 opened 2 months ago

czy-29 commented 2 months ago

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.

kaffarell commented 2 months ago

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 commented 2 months ago

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.