mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-19 19:25:41 +02:00
parent
739dc30323
commit
1a323c6d21
2 changed files with 11 additions and 3 deletions
|
@ -16,6 +16,8 @@
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
* environment variable substitution in config files ([#96][96]).
|
* environment variable substitution in config files ([#96][96]).
|
||||||
|
* Log output now respects the [`NO_COLOR`](http://no-color.org/)
|
||||||
|
environment variable.
|
||||||
|
|
||||||
[96]: https://codeberg.org/dnkl/yambar/issues/96
|
[96]: https://codeberg.org/dnkl/yambar/issues/96
|
||||||
|
|
||||||
|
|
12
log.c
12
log.c
|
@ -39,9 +39,15 @@ log_init(enum log_colorize _colorize, bool _do_syslog, enum log_facility syslog_
|
||||||
[LOG_FACILITY_DAEMON] = LOG_DAEMON,
|
[LOG_FACILITY_DAEMON] = LOG_DAEMON,
|
||||||
};
|
};
|
||||||
|
|
||||||
colorize = _colorize == LOG_COLORIZE_NEVER ? false
|
/* Don't use colors if NO_COLOR is defined and not empty */
|
||||||
: _colorize == LOG_COLORIZE_ALWAYS ? true
|
const char *no_color_str = getenv("NO_COLOR");
|
||||||
: isatty(STDERR_FILENO);
|
const bool no_color = no_color_str != NULL && no_color_str[0] != '\0';
|
||||||
|
|
||||||
|
colorize = _colorize == LOG_COLORIZE_NEVER
|
||||||
|
? false
|
||||||
|
: _colorize == LOG_COLORIZE_ALWAYS
|
||||||
|
? true
|
||||||
|
: !no_color && isatty(STDERR_FILENO);
|
||||||
do_syslog = _do_syslog;
|
do_syslog = _do_syslog;
|
||||||
log_level = _log_level;
|
log_level = _log_level;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue