From 252da0b8341ef92f78b448b506a7484dad6ef25d Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Sun, 14 Sep 2025 17:53:33 +0530 Subject: [PATCH] Fix setting debug log level --- libbbfdm-api/legacy/dmubus.c | 2 +- libbbfdm-ubus/bbfdm-ubus.c | 12 +++++++++--- libbbfdm-ubus/bbfdm-ubus.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libbbfdm-api/legacy/dmubus.c b/libbbfdm-api/legacy/dmubus.c index 6a9f7d98..e65885db 100644 --- a/libbbfdm-api/legacy/dmubus.c +++ b/libbbfdm-api/legacy/dmubus.c @@ -701,7 +701,7 @@ static void dmubus_schedule_blacklisted_ubus_recovery(void) } } - BBF_DEBUG("Next blacklisted ubus recovery scheduled in %d msecs", next_check_time); + BBF_DEBUG("Pid %d, Next blacklisted ubus recovery scheduled in %d msecs", getpid(), next_check_time); uloop_timeout_set(&blacklisted_ubus_recovery_timer, next_check_time); } diff --git a/libbbfdm-ubus/bbfdm-ubus.c b/libbbfdm-ubus/bbfdm-ubus.c index e5ed69a2..39df64f1 100644 --- a/libbbfdm-ubus/bbfdm-ubus.c +++ b/libbbfdm-ubus/bbfdm-ubus.c @@ -35,6 +35,7 @@ // Global variables static void *deamon_lib_handle = NULL; +static uint8_t s_log_level = 0xff; static void bbfdm_ctx_cleanup(struct bbfdm_context *u) { @@ -963,7 +964,7 @@ static void register_bbfdm_apply_event(struct bbfdm_context *bbfdm_ctx) int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx) { - int err = 0, cur_log_mask=0; + int err = 0; err = ubus_connect_ctx(&bbfdm_ctx->ubus_ctx, NULL); if (err != UBUS_STATUS_OK) { @@ -972,8 +973,7 @@ int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx) } // Set the logmask with default, if not already set by api - cur_log_mask = setlogmask(0); - if (cur_log_mask == 0xff) { + if (s_log_level == 0xff) { BBF_INFO("Log level not set, setting default value %d", LOG_ERR); bbfdm_ubus_set_log_level(LOG_ERR); } @@ -1031,6 +1031,12 @@ void bbfdm_ubus_set_service_name(struct bbfdm_context *bbfdm_ctx, const char *sr void bbfdm_ubus_set_log_level(int log_level) { setlogmask(LOG_UPTO(log_level)); + s_log_level = log_level; +} + +uint8_t bbfdm_ubus_get_log_level(void) +{ + return s_log_level; } void bbfdm_ubus_load_data_model(DM_MAP_OBJ *DynamicObj) diff --git a/libbbfdm-ubus/bbfdm-ubus.h b/libbbfdm-ubus/bbfdm-ubus.h index 59853935..257192d9 100644 --- a/libbbfdm-ubus/bbfdm-ubus.h +++ b/libbbfdm-ubus/bbfdm-ubus.h @@ -51,6 +51,8 @@ int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx); int bbfdm_print_data_model_schema(struct bbfdm_context *bbfdm_ctx, const enum bbfdm_type_enum type); void bbfdm_ubus_set_service_name(struct bbfdm_context *bbfdm_ctx, const char *srv_name); + +uint8_t bbfdm_ubus_get_log_level(void); void bbfdm_ubus_set_log_level(int log_level); void bbfdm_ubus_load_data_model(DM_MAP_OBJ *DynamicObj); int bbfdm_refresh_references(unsigned int dm_type, const char *srv_obj_name);