]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools-common.h: add logging helpers
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 22 Mar 2022 10:03:41 +0000 (15:33 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 24 Mar 2022 14:03:42 +0000 (08:03 -0600)
fprintf(stderr, ...); is used across the tools to notify the user about
something that went wrong and needs to abort. Similarly, printf() is
used to print information, may continue with the code execution.

This patch adds helper macro err(), info(), that can replace messaging
printing to stderr/stdout, making code readable and compact.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/tools-common.h

index b3e15f3c06c1c302a842f88970c6ecea89f1ef18..cbc9610ff8839d79628f24e912c9472957c22967 100644 (file)
@@ -24,6 +24,9 @@ extern "C" {
 #define cgroup_info(x...) cgroup_log(CGROUP_LOG_INFO, "Info: " x)
 #define cgroup_dbg(x...) cgroup_log(CGROUP_LOG_DEBUG, x)
 
+#define err(x...)      fprintf(stderr, x)
+#define info(x...)     fprintf(stdout, x)
+
 /**
  * Auxiliary specifier of group, used to store parsed command line options.
  */