mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04: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
|
|
@ -65,11 +65,14 @@
|
||||||
* Support for SGR 21 (double underline).
|
* Support for SGR 21 (double underline).
|
||||||
* Support for `XTPUSHCOLORS`, `XTPOPCOLORS` and `XTREPORTCOLORS`,
|
* Support for `XTPUSHCOLORS`, `XTPOPCOLORS` and `XTREPORTCOLORS`,
|
||||||
i.e. color palette stack ([#856][856]).
|
i.e. color palette stack ([#856][856]).
|
||||||
|
* Log output now respects the [`NO_COLOR`](http://no-color.org/)
|
||||||
|
environment variable ([#1771][1771]).
|
||||||
|
|
||||||
[1707]: https://codeberg.org/dnkl/foot/issues/1707
|
[1707]: https://codeberg.org/dnkl/foot/issues/1707
|
||||||
[1738]: https://codeberg.org/dnkl/foot/issues/1738
|
[1738]: https://codeberg.org/dnkl/foot/issues/1738
|
||||||
[828]: https://codeberg.org/dnkl/foot/issues/828
|
[828]: https://codeberg.org/dnkl/foot/issues/828
|
||||||
[856]: https://codeberg.org/dnkl/foot/issues/856
|
[856]: https://codeberg.org/dnkl/foot/issues/856
|
||||||
|
[1771]: https://codeberg.org/dnkl/foot/issues/1771
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
8
log.c
8
log.c
|
|
@ -40,7 +40,13 @@ log_init(enum log_colorize _colorize, bool _do_syslog,
|
||||||
[LOG_FACILITY_DAEMON] = LOG_DAEMON,
|
[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;
|
do_syslog = _do_syslog;
|
||||||
log_level = _log_level;
|
log_level = _log_level;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue