json-util: fine tune json_dispatch_log_level()

Let's give the user control on how to handle JSON "null" assignments of
the log level. As one of three cases: as failure, as LOG_NULL (i.e. to
turn off logging) or as LOG_INFO (as our usual default log level).

Let's then use that in the generic SetLogLevel() call, so that callers
can use it to explicitly turn off logging in a service.

Note that this was (probably accidentally) already implemented, except
that the introspection enforcement blocked it. Let's clean this up and
make this officially a thing, since it's generally useful to turn off
logging I think.
This commit is contained in:
Lennart Poettering
2025-01-18 23:24:29 +01:00
parent a153d7cbd2
commit fa3137f9d0
3 changed files with 14 additions and 5 deletions
+1
View File
@@ -34,6 +34,7 @@ typedef enum LogTarget{
/* This log level disables logging completely. It can only be passed to log_set_max_level() and cannot be
* used as a regular log level. */
#define LOG_NULL (LOG_EMERG - 1)
assert_cc(LOG_NULL == -1);
#define SYNTHETIC_ERRNO(num) (abs(num) | (1 << 30))
#define IS_SYNTHETIC_ERRNO(val) (((val) >> 30) == 1)