aboutsummaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/log.c b/log.c
index d19adaca..ebf411ec 100644
--- a/log.c
+++ b/log.c
@@ -40,7 +40,13 @@ log_init(enum log_colorize _colorize, bool _do_syslog,
[LOG_FACILITY_DAEMON] = LOG_DAEMON,
};
- colorize = _colorize == LOG_COLORIZE_ALWAYS || (_colorize == LOG_COLORIZE_AUTO && isatty(STDERR_FILENO));
+ /* Don't use colors if NO_COLOR is defined and not empty */
+ const char *no_color_str = getenv("NO_COLOR");
+ const bool no_color = no_color_str != NULL && no_color_str[0] != '\0';
+
+ colorize = _colorize == LOG_COLORIZE_ALWAYS
+ || (_colorize == LOG_COLORIZE_AUTO
+ && !no_color && isatty(STDERR_FILENO));
do_syslog = _do_syslog;
log_level = _log_level;