From: Kamalesh Babulal Date: Fri, 11 Mar 2022 14:51:09 +0000 (-0700) Subject: log: add log level string prefix to logging functions X-Git-Tag: v3.0~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97a0e195ddd7;p=thirdparty%2Flibcgroup.git log: add log level string prefix to logging functions 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 Signed-off-by: Tom Hromatka --- diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h index 708bf25a..3c152ea9 100644 --- a/src/libcgroup-internal.h +++ b/src/libcgroup-internal.h @@ -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 diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h index e3541b17..515c4955 100644 --- a/src/tools/tools-common.h +++ b/src/tools/tools-common.h @@ -25,9 +25,9 @@ extern "C" { #include #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) /**