mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Don't enable colors when stdout is redirected to a file (fixes #5233)
This commit is contained in:
parent
8e3d5c1b59
commit
d2e9a78483
|
@ -11,6 +11,8 @@
|
|||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501 /* required for mingw to get getaddrinfo to work */
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
@ -369,7 +371,8 @@ std::unique_ptr<ILogger> log_logger_stdout()
|
|||
#if !defined(CONF_FAMILY_WINDOWS)
|
||||
// TODO: Only enable true color when COLORTERM contains "truecolor".
|
||||
// https://github.com/termstandard/colors/tree/65bf0cd1ece7c15fa33a17c17528b02c99f1ae0b#checking-for-colorterm
|
||||
return std::unique_ptr<ILogger>(new CLoggerAsync(io_stdout(), getenv("NO_COLOR") == nullptr, false));
|
||||
const bool colors = getenv("NO_COLOR") == nullptr && isatty(STDOUT_FILENO);
|
||||
return std::unique_ptr<ILogger>(new CLoggerAsync(io_stdout(), colors, false));
|
||||
#else
|
||||
if(GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_UNKNOWN)
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
|
|
Loading…
Reference in a new issue