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

no colors when using feature stderr and redirecting stdout #71

Closed
andbleo opened this issue Dec 22, 2022 · 5 comments
Closed

no colors when using feature stderr and redirecting stdout #71

andbleo opened this issue Dec 22, 2022 · 5 comments

Comments

@andbleo
Copy link

andbleo commented Dec 22, 2022

When I have the stderr and colors features enabled and redirect just stdout, the colors in my stderr logs are no longer there. If I remove the stderr feature and try redirecting stderr, my stdout logs do have color. Is this expected behavior?

This is on macOS and happens in both iTerm2 and the vs code terminal.

Here is how I pull in simple_logger in Cargo.toml: simple_logger = { version = "4.0.0", features = ["stderr"] }

@borntyping
Copy link
Owner

I don't think this is expected. I can't see any reason this would happen - the colors and stderr features are pretty separate. Do you get coloured logs if you enable colors and stderr without redirecting any output?

I can see a potential bug in the code where this might happen on Windows specifically: https://github.com/borntyping/rust-simple_logger/blob/main/src/lib.rs#L463

@andbleo
Copy link
Author

andbleo commented Dec 22, 2022

I do get colors when I don't redirect stdout.
Perhaps it is a bug in the colored dependency for non-windows platforms?

@borntyping
Copy link
Owner

Ah: this does look like it may be a bug in colored, which checks STDOUT to decide if it should show colours.

https://docs.rs/colored/latest/src/colored/control.rs.html#108

@andbleo
Copy link
Author

andbleo commented Dec 24, 2022

I will open an issue with colored and link to this one.

@borntyping
Copy link
Owner

Closing this as it looks like it's currently intended behavior on coloured's part.

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