[Bug] colorlog.basicConfig() doesn't seems to work when upgrading from v5 to v6
EmrysMyrddin opened this issue · comments
Hi,
I've just updated colorlog on my project from v5 to v6, but colors stopped showing up in the console.
It seems that it comes from the merge of TTYColoredFormatter
and ColoredFormatter
.
The _blank_escape_codes
function is returning true when os.stdout
is passed as the stream
parameter.
I suppose that this is an heuristic to avoid printing escape codes into the some non compatible strem, but the condition is too broad. For example, in most IDE, the stdout is not linked to a TTY but handles colors very well.
Perhaps the better fix, to avoid breaking change is to add an optional parameter like force_colors
?
This is working correctly, though the implementation of colorlog.basicConfig
passing stream
to both logging.basicConfig
and colorlog.formatter.ColoredFormatter
is somewhat awkward. Normally the way to force colors would be to not pass stream
to colorlog.formatter.ColoredFormatter
at all.
I'd be happy to merge an MR adding support for a FORCE_COLOR
environment variable or force_color
option (matching the existing NO_COLOR
/no_color
). I'll implement that myself if no-one else does, though it'll be whenever I have time.
Implemented and released in 6.6.0. :)
Wow ! Thank you a lot for your reactivity !
This package is really great, thank you for all :-)