TSG-22082: support set split log file by size

This commit is contained in:
root
2024-08-07 08:47:15 +00:00
parent 2fd93a1648
commit d114221ebe
6 changed files with 54 additions and 4 deletions

View File

@@ -113,6 +113,7 @@ struct maat_options {
char decrypt_key[MAX_KEYWORDS_STR_LEN];
char log_path[PATH_MAX];
int log_level;
size_t log_file_max_size_mb;
char stat_file[NAME_MAX];
size_t nr_worker_thread;
char *accept_tags;

View File

@@ -77,6 +77,7 @@ struct maat_options* maat_options_new(void)
options->input_mode = DATA_SOURCE_NONE;
options->expr_engine = MAAT_EXPR_ENGINE_AUTO;
options->log_level = 0;
options->log_file_max_size_mb = 500;
return options;
}
@@ -311,6 +312,17 @@ int maat_options_set_logger(struct maat_options *opts, const char *log_path,
return 0;
}
int maat_options_set_log_file_max_size(struct maat_options *opts, size_t max_size_mb)
{
if (NULL == opts || max_size_mb <= 0) {
return -1;
}
opts->log_file_max_size_mb = max_size_mb;
return 0;
}
static void _maat_free(struct maat *maat_inst)
{
if (NULL == maat_inst) {
@@ -365,6 +377,9 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
}
maat_inst->logger = log_handle_create(log_path, maat_inst->opts.log_level);
}
if (maat_inst->opts.log_file_max_size_mb != 0) {
log_handle_set_file_max_size(maat_inst->logger, maat_inst->opts.log_file_max_size_mb);
}
if (NULL == maat_inst->logger) {
fprintf(stderr, "create log handle failed.\n");

View File

@@ -243,9 +243,9 @@ static void fs_table_row_output(FILE *fp, struct maat_stat *stat, int perf_on)
long long total_scan_times = 0, total_hit_times = 0, total_scan_cpu_time = 0;
long long total_regv6_num = 0, total_hit_item_num = 0, total_hit_pattern_num = 0;
long long g2c_not_clause_num = 0, g2g_excl_rule_num = 0;
struct fieldstat_tag cell_tag = {
struct field cell_tag = {
.key = "TBL",
.type = TAG_CSTRING
.type = FIELD_VALUE_CSTRING
};
size_t max_table_count = table_manager_table_size(stat->ref_tbl_mgr);