diff options
author | Ray Molenkamp <github@lazydodo.com> | 2020-09-10 20:31:09 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2020-09-10 20:31:09 +0300 |
commit | 9bd10b1c9218e65d9de57e9a95dd5d77d5b9243a (patch) | |
tree | 38893e3cff5dd2c77a93d81394fbb7fc2fc17b23 | |
parent | 359acad5e49bb23a603706c47a05b9ffc1c92d33 (diff) |
CLog: Support colorized logging on windows
When using Windows Terminal the same control codes Linux
uses to colorize the text can be used. WT can be detected
by looking at the WT_SESSION environment variable.
Differential Revision: https://developer.blender.org/D8848
Reviewed by: campbellbarton
-rw-r--r-- | intern/clog/clog.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/intern/clog/clog.c b/intern/clog/clog.c index 17c9d49ee51..1cebd9f2099 100644 --- a/intern/clog/clog.c +++ b/intern/clog/clog.c @@ -548,6 +548,14 @@ static void CLG_ctx_output_set(CLogContext *ctx, void *file_handle) ctx->output = fileno(ctx->output_file); #if defined(__unix__) || defined(__APPLE__) ctx->use_color = isatty(ctx->output); +#elif defined(WIN32) + /* Windows Terminal supports color like the Linux terminals do while the standard console does + * not, the way to tell the two apart is to look at the WT_SESSION environment variable which + * will only be defined for Windows Terminal. */ + + /* getenv is used here rather than BLI_getenv since there are no benefits for using it in this + * context. */ + ctx->use_color = isatty(ctx->output) && getenv("WT_SESSION"); #endif } |