-
Notifications
You must be signed in to change notification settings - Fork 34
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-subscriber output? #20
Comments
I think it would be fine, as long as the check does not introduce another dependency. So pulling in |
Ah, OK, I was originally thinking we could just always disable ANSI for test output, but maybe it's useful for interactive cargo test invocations... In that case, probably keying off of |
Maybe this could also support NO_COLOR. |
I tied to implement this, seems SubscriberBuilder::with_ansi require the Do you think should it be enabled by default? Or guarded by another new trait so we don't break backward compatibility |
Nice!
By default we should keep colors, in my opinion. It's how everything else behaves by default. I'd say if we follow the char *no_color = getenv("NO_COLOR");
bool color = true;
if (no_color != NULL && no_color[0] != '\0')
color = false;
/* do getopt(3) and/or config-file parsing to possibly turn color back on */ So according to that we should just check for the existence of the env variable. Though I suppose special casing |
Also (and I haven't tested that), as mentioned earlier currently it seems as if |
|
The default behavior of tracing-subscriber is to include color control codes in output. It does not try to detect whether the output is a terminal as part of this: tokio-rs/tracing#1160.
For test output this is pretty bad, since it means the color control codes get into logs and end up causing downstream log processing code to complain. Would it be reasonable to disable ANSI output (via SubscriberBuilder::with_ansi) in
expand_tracing_init()
? I'd be happy to send a patch.The text was updated successfully, but these errors were encountered: