borntyping / rust-simple_logger

A rust logger that prints all messages with a readable output format.
https://crates.io/crates/simple_logger
MIT License
220 stars 48 forks source link

Fix stderr color dependence on stdout #91

Closed spoutn1k closed 3 months ago

spoutn1k commented 3 months ago

Hello,

I work with programs that pipe stdout often. simple_logger would simply not print colored output to stderr when that happened. This is due to this colored issue.

This PR aims to fix this by implementing a variation of the set_up_color_terminal function, enabled when the stderr feature is selected on other platforms than Windows (For lack of testing environment).

spoutn1k commented 3 months ago

I renamed the references to the coloring feature from colored to colors as is defined here: https://github.com/borntyping/rust-simple_logger/blob/f12a2b392a9337560561230204f9ceeebf9c3265/Cargo.toml#L10-L12

That may be a mistake please let me know if I should roll that back.

borntyping commented 3 months ago

Thanks! I think this will fix https://github.com/borntyping/rust-simple_logger/issues/71 too.

I renamed the references to the coloring feature from colored to colors as is defined here

I think this change makes sense, I'm not really sure why it was written that way, since coloured is a dependency not a feature.

There's some documentation around set_up_color_terminal in the README that will need updating. (I'll do it when I merge and release this—hopefully later today or this week—if you don't get there first!)

borntyping commented 3 months ago

Released in 5.0.0.