[FEATURE]maat support dynamic reload log_level

This commit is contained in:
liuwentan
2023-12-05 16:31:18 +08:00
parent f48afd54f6
commit 59ee9364c9
9 changed files with 98 additions and 122 deletions

View File

@@ -353,7 +353,7 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
if (strlen(maat_inst->opts.log_path) != 0) {
maat_inst->logger = log_handle_create(maat_inst->opts.log_path,
maat_inst->opts.log_level);
maat_inst->opts.log_level);
} else {
char log_path[MAX_NAME_STR_LEN] = {0};
if (strlen(maat_inst->opts.inst_name) > 0) {
@@ -443,6 +443,12 @@ void maat_free(struct maat *maat_inst)
pthread_join(maat_inst->cfg_mon_thread, &ret);
}
void maat_reload_log_level(struct maat *maat_inst, enum log_level level)
{
maat_inst->opts.log_level = level;
log_handle_set_level(maat_inst->logger, level);
}
__thread int _thread_local_tid = -1;
void maat_register_thread(struct maat *maat_inst)
{
@@ -542,7 +548,8 @@ int maat_table_callback_register(struct maat *maat_inst, int table_id,
if (table_type != TABLE_TYPE_PLUGIN) {
pthread_mutex_unlock(&(maat_inst->background_update_mutex));
log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table type:%d illegal", __FUNCTION__, __LINE__, table_type);
"[%s:%d] table type:%d illegal",
__FUNCTION__, __LINE__, table_type);
return -1;
}

View File

@@ -1370,7 +1370,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
}
}
return ret;
return 0;
}
static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
@@ -1450,7 +1450,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
}
}
return ret;
return 0;
}
struct compile_state *compile_state_new(void)

View File

@@ -181,10 +181,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
continue;
}
ret = update_fn(index->table_name, line, u_param);
if (ret < 0) {
break;
}
update_fn(index->table_name, line, u_param);
}
FREE(file_buff);

View File

@@ -6,6 +6,7 @@ global:
maat_new;
maat_free;
maat_get_table_id;
maat_reload_log_level;
maat_table*;
maat_compile_table*;
maat_plugin_table*;