Skip to content

Commit

Permalink
libhfcommon/log: respect NO_COLOR envar
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed May 28, 2023
1 parent 37e8e81 commit 1f09e3b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libhfcommon/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ __attribute__((constructor)) static void log_init(void) {
hf_log_fd = STDERR_FILENO;
}
hf_log_fd_isatty = isatty(hf_log_fd);

if (getenv("NO_COLOR")) {
hf_log_fd_isatty = false;
}
}

/*
Expand All @@ -80,6 +84,10 @@ void logInitLogFile(const char* logfile, int fd, enum llevel_t ll) {
}

hf_log_fd_isatty = (isatty(hf_log_fd) == 1 ? true : false);

if (getenv("NO_COLOR")) {
hf_log_fd_isatty = false;
}
}

void logLog(enum llevel_t ll, const char* fn, int ln, bool perr, const char* fmt, ...) {
Expand Down

0 comments on commit 1f09e3b

Please sign in to comment.