From 819ea21f5993993ad17ff55e410a4491a11d18e7 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Tue, 22 Mar 2022 15:33:41 +0530 Subject: [PATCH] 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 --- src/tools/tools-common.h | 3 +++ 1 file changed, 3 insertions(+) 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. */ -- 2.47.2