log: fix syslog not respecting the configured log level

This commit is contained in:
Daniel Eklöf 2024-04-05 16:11:37 +02:00
parent da19c09122
commit 28a18ad91e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 5 additions and 1 deletions

View file

@ -48,6 +48,7 @@
* i3/sway: module fails when reloading config file ([#361][361]). * i3/sway: module fails when reloading config file ([#361][361]).
* Worked around bug in gcc causing a compilation error ([#350][350]). * Worked around bug in gcc causing a compilation error ([#350][350]).
* Miscalculation of list width in presence of empty particles ([#369][369]). * Miscalculation of list width in presence of empty particles ([#369][369]).
* Log-level not respected by syslog.
[311]: https://codeberg.org/dnkl/yambar/issues/311 [311]: https://codeberg.org/dnkl/yambar/issues/311
[302]: https://codeberg.org/dnkl/yambar/issues/302 [302]: https://codeberg.org/dnkl/yambar/issues/302

5
log.c
View file

@ -15,7 +15,7 @@
#define UNUSED __attribute__((unused)) #define UNUSED __attribute__((unused))
static bool colorize = false; static bool colorize = false;
static bool do_syslog = true; static bool do_syslog = false;
static enum log_class log_level = LOG_CLASS_NONE; static enum log_class log_level = LOG_CLASS_NONE;
static const struct { static const struct {
@ -102,6 +102,9 @@ _sys_log(enum log_class log_class, const char *module,
if (!do_syslog) if (!do_syslog)
return; return;
if (log_class > log_level)
return;
/* Map our log level to syslog's level */ /* Map our log level to syslog's level */
int level = log_level_map[log_class].syslog_equivalent; int level = log_level_map[log_class].syslog_equivalent;