easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

Use ANSI color code only when isatty(1) == 1

Open sswv opened this issue 7 years ago • 1 comments

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!

sswv avatar May 24 '17 06:05 sswv

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.

habeebq avatar Jul 23 '19 09:07 habeebq