From: Kamalesh Babulal Date: Tue, 22 Mar 2022 10:03:41 +0000 (+0530) Subject: tools-common.h: add logging helpers X-Git-Tag: v3.0~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=819ea21f5993993ad17ff55e410a4491a11d18e7;p=thirdparty%2Flibcgroup.git tools-common.h: add logging helpers 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 Signed-off-by: Tom Hromatka --- diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h index b3e15f3c..cbc9610f 100644 --- a/src/tools/tools-common.h +++ b/src/tools/tools-common.h @@ -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. */