]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
log: add log level string prefix to logging functions
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 11 Mar 2022 14:51:09 +0000 (07:51 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 11 Mar 2022 14:51:15 +0000 (07:51 -0700)
Usage of cgroup_{err, warn, info} functions, expects the log level to be
prefixed to the message like: cgroup_warn("Warning: ...").  This patch
removes this need to prefix and automatically adds the desired prefix to
the logger function, so the usage becomes cgroup_warn("...").  This
helps in readability and avoiding typos in setting the right log level
string to the message.

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

index 708bf25ac39fa73b9829965fa9c9c698e172ba57..3c152ea92b533b3ab4f78f598c64c5c82597f134 100644 (file)
@@ -79,10 +79,10 @@ extern "C" {
 
 #define CGROUP_FILE_PREFIX     "cgroup"
 
-#define cgroup_err(x...)       cgroup_log(CGROUP_LOG_ERROR, x)
-#define cgroup_warn(x...)      cgroup_log(CGROUP_LOG_WARNING, x)
-#define cgroup_info(x...)      cgroup_log(CGROUP_LOG_INFO, x)
-#define cgroup_dbg(x...)       cgroup_log(CGROUP_LOG_DEBUG, x)
+#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, "Error: " x)
+#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_DEFAULT_LOGLEVEL CGROUP_LOG_ERROR
 
index e3541b17fda7f59937ea96011ddaf878a3bbe82c..515c49557755febc53872eb258a8e6f3a728f7cf 100644 (file)
@@ -25,9 +25,9 @@ extern "C" {
 #include <libcgroup.h>
 #include "../libcgroup-internal.h"
 
-#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, x)
-#define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, x)
-#define cgroup_info(x...) cgroup_log(CGROUP_LOG_INFO, x)
+#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, "Error: " x)
+#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)
 
 /**