]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
log: introduce CGROUP_LOG_CONT level for logging
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 23 Aug 2022 17:21:47 +0000 (11:21 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 23 Aug 2022 17:21:54 +0000 (11:21 -0600)
commit24b5087cbf80924e50b7b20a143a81baeff69770
tree5570b3c0695f916d6eeb41c516fcd2fa616e2b3c
parented283eab173addd3b5c2dd666de8f3086125e106
log: introduce CGROUP_LOG_CONT level for logging

There are cases, where we might want to print a very long/multiline log
message to the user. We could call the cgroup_log(), multiple times to
fit the log message, but the downside is that every time the
cgroup_log() called, the log level is prefixed to the message, hence
introducing loglevel char string in the mid of the log message.
For example, calling the cgroup_warn() twice to print a long warning:

cgroup_warn("cgroup v1 expects /proc/cgroup, check if ");
cgroup_warn("/proc mounted with subset=pid option\n");

output:
-------
$ sudo CGROUP_LOGLEVEL=DEBUG ./src/tools/cgget -g cpu:user.slice
...
Warning: cgroup v1 expects /proc/cgroup, check if Warning: /proc mounted
with subset=pid option

Introduce a new logging level, CGROUP_LOG_CONT and cgroup_cont() macro,
that will continue printing the log message, when loglevel is set to other
than default log level. The above code can be rewritten as:

cgroup_warn("cgroup v1 expects/proc/cgroup, check if ");
cgroup_cont("/proc mounted with subset=pid option\n");

output:
-------
$ sudo CGROUP_LOGLEVEL=DEBUG ./src/tools/cgget -g cpu:user.slice
...
Warning: cgroup v1 expects /proc/cgroup, check if /proc mounted with
subset=pid option

Also, make comsetic changes to cgroup_*().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
include/libcgroup/log.h
src/libcgroup-internal.h