emilk / loguru

A lightweight C++ logging library
The Unlicense
1.79k stars 260 forks source link

Check isatty() to decide if colors are supported #127

Closed oriolarcas closed 4 years ago

oriolarcas commented 4 years ago

Currently, the type of terminal ($TERM) is checked in s_terminal_has_color() to decide if colors are supported. However, the stderr can be redirected to a file or another process which doesn't support colors. To check if stderr is being received by a terminal, at least the isatty() POSIX function must be called.

More advanced checks like ttyname() could be used.

emilk commented 4 years ago

Thanks!