From d0becd6c53781d4233a3f82b7b9faa8d5108a606 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Mon, 13 Jan 2025 11:17:13 -0700 Subject: [PATCH] api: log: Add cgroup_get_loglevel() Add a publicly-exposed function to get the current libcgroup logging level. Signed-off-by: Tom Hromatka Acked-by: Kamalesh Babulal --- include/libcgroup/log.h | 6 ++++++ src/libcgroup.map | 1 + src/log.c | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/include/libcgroup/log.h b/include/libcgroup/log.h index b65b8d39..19152a45 100644 --- a/include/libcgroup/log.h +++ b/include/libcgroup/log.h @@ -132,6 +132,12 @@ extern void cgroup_set_default_logger(int loglevel); */ extern void cgroup_set_loglevel(int loglevel); +/** + * Retrieve the current loglevel. + * @return the current loglevel from with libcgroup + */ +extern int cgroup_get_loglevel(void); + /** * Libcgroup log function. This is for applications which are too lazy to set * up their own complex logging and miss-use libcgroup for that purpose. diff --git a/src/libcgroup.map b/src/libcgroup.map index bf1d2ed7..4ab5e752 100644 --- a/src/libcgroup.map +++ b/src/libcgroup.map @@ -168,4 +168,5 @@ CGROUP_3.0 { CGROUP_3.2 { cgroup_get_threads; + cgroup_get_loglevel; } CGROUP_3.0; diff --git a/src/log.c b/src/log.c index c9bc8260..4154d82b 100644 --- a/src/log.c +++ b/src/log.c @@ -90,3 +90,8 @@ void cgroup_set_loglevel(int loglevel) cgroup_loglevel = CGRP_DEFAULT_LOGLEVEL; } } + +int cgroup_get_loglevel(void) +{ + return cgroup_loglevel; +} -- 2.47.3