mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
log: respect the NO_COLOR environment variable
http://no-color.org/ Closes #1771
This commit is contained in:
parent
4f25e1ba9f
commit
36e4435bbf
2 changed files with 10 additions and 1 deletions
8
log.c
8
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue