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

Disable ansi for tracing_tracy #123

Open
TheCodeLamp opened this issue Nov 5, 2024 · 2 comments
Open

Disable ansi for tracing_tracy #123

TheCodeLamp opened this issue Nov 5, 2024 · 2 comments

Comments

@TheCodeLamp
Copy link

I don't believe tracy can display ansi characters so it's just added characters that obfuscate span names.
I saw that ansi support for tracing_subscriber is a feature flag so it might only be possible to disable this if that flag is turned on. But it seems it's possible to set the .with_ansi(false) on a fmt layer even without the ansi flag enabled.

It's possible to disable this by setting the NO_COLOR env flag, but I feel like the tracing layer shouldn't submit color characters by default.

Relevant issue: #72

Maybe relevant links?:
https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_ansi
https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.set_ansi

@nagisa
Copy link
Owner

nagisa commented Nov 5, 2024

Fundamentally this is happening because TracyFields is likely the same type as the fields saved to extensions by some other layer that goes out of their way to enable ansi and format the text with the escape codes enabled. The tracy layer then just picks up the cached value.

Otherwise tracy layer with DefaultConfig should not produce ansi escapes.

We could change TracyFields to be its own unique type, but that would lead to reformatting the same messages multiple times for each layer, which is suboptimal too.

While I agree that it would be ideal that tracy worked correctly at all times, this can already be handled by the users by implementing their own Config that returns a different Formatter (new-)type as well. That way they can opt into double work if they wish. Or they could re-order the layers as seen in #72 so that ANSI-less formatter goes first -- but that would then conversely make other layers output tracy-formatted text (without ANSI colour.)

@TheCodeLamp
Copy link
Author

Thank you for your response. I was suspecting that this was something that was difficult to implement. For my use case just disabling all color using NO_COLOR is ideal as I don't directly touch the tracy layer (I use bevy), and when I profile I can live without color. I hope this helps someone with a similar issue though.

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

No branches or pull requests

2 participants