summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Swiecki <robert@swiecki.net>2023-05-28 09:10:53 +0200
committerRobert Swiecki <robert@swiecki.net>2023-05-28 09:10:53 +0200
commit1f09e3bfb0785d9b31132ce84ec42f6293d49d9e (patch)
tree6dc3d7c39334b1c8b49338e8bbba2e7b01649a28
parent37e8e813c9daa94dff29654b262268481d8c53ee (diff)
downloadhonggfuzz-1f09e3bfb0785d9b31132ce84ec42f6293d49d9e.tar.gz
libhfcommon/log: respect NO_COLOR envar
-rw-r--r--libhfcommon/log.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libhfcommon/log.c b/libhfcommon/log.c
index 27b3e444..f2e56681 100644
--- a/libhfcommon/log.c
+++ b/libhfcommon/log.c
@@ -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;
+ }
}
/*
@@ -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, ...) {