Fix setting debug log level

This commit is contained in:
Amin Ben Romdhane 2025-11-25 09:35:32 +00:00 committed by IOPSYS Dev
parent 348d448d3a
commit 6317266bdf
No known key found for this signature in database
3 changed files with 12 additions and 4 deletions

View file

@ -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);
}

View file

@ -34,6 +34,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)
{
@ -779,7 +780,7 @@ int bbfdm_print_data_model_schema(struct bbfdm_context *bbfdm_ctx, const enum bb
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) {
@ -788,8 +789,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);
}
@ -843,6 +843,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)

View file

@ -50,6 +50,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);