clux / loggerv

A minimalistic stdout/stderr logger for rust
https://docs.rs/loggerv
MIT License
21 stars 6 forks source link

Disable ansi color when either stdout or stderr isn't a tty #3

Closed compenguy closed 7 years ago

compenguy commented 7 years ago

One of the benefits of logging is dumping the output to a text file for later review.

This change modifies loggerv so that it only prints ansi codes when stdout and stderr are both connect to a controlling terminal. On the other hand, when either is being redirected, color is disabled.

Ideally color would be disabled for stdout and stderr separately, but this change is small, to the point, and takes it 90% of the way to where it wants to be.

clux commented 7 years ago

Hey thanks for this!

I've looked at it briefly, seems to make sense. Not 100% sure about the check and how it maps onto normal --color=auto usage, but it seems like a sensible starting point. Did some tweaks to it in #4, will probably merge it later today.

clux commented 7 years ago

Published in 0.4.0