easyloggingpp
easyloggingpp copied to clipboard
Use ANSI color code only when isatty(1) == 1
Now ANSI color code is always used in convertToColoredOutput when ColoredTerminalOutput is set. It will print control characters even when the stdout is redirect to a file or pipe. I think it is better to use ANSI color code only when running in a terminal. It is possible to use isatty
in unistd.h
or _isatty
in io.h
to detect this. Thanks!
I'm also seeing this issue. I agree that in termSupportsColor, instead of just checking the environment for TERM, you also need to check isatty otherwise otherwise when you redirect to a file/pipe you need to scrub the escape codes manually, or they appear in the file.