]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/tools-common.h: introduce CGROUP_LOG_CONT level for logging
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 23 Aug 2022 17:22:04 +0000 (11:22 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 23 Aug 2022 17:22:54 +0000 (11:22 -0600)
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.

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:

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Fix typo in commit message

src/tools/tools-common.h

index 20ce28aa4f85366d0e69654136df1cc49914e771..5f3d55f1207084b8fd16cfc9164dcb4b8c228cb0 100644 (file)
@@ -23,6 +23,7 @@ extern "C" {
 #define cgroup_warn(x...)      cgroup_log(CGROUP_LOG_WARNING, "Warning: " x)
 #define cgroup_info(x...)      cgroup_log(CGROUP_LOG_INFO, "Info: " x)
 #define cgroup_dbg(x...)       cgroup_log(CGROUP_LOG_DEBUG, x)
+#define cgroup_cont(x...)      cgroup_log(CGROUP_LOG_CONT, x)
 
 #define err(x...)      fprintf(stderr, x)
 #define info(x...)     fprintf(stdout, x)