maat_options set logger -> set log_path

This commit is contained in:
liuwentan
2023-03-16 15:16:42 +08:00
parent 6afb0a0194
commit 8312b69fda
8 changed files with 160 additions and 134 deletions

View File

@@ -17,6 +17,7 @@ extern "C"
#endif
#include <stddef.h>
#include <limits.h>
#include "log/log.h"
#include "maat_rule.h"
@@ -24,6 +25,7 @@ extern "C"
struct maat_options {
char instance_name[NAME_MAX];
char foreign_cont_dir[NAME_MAX];
char log_path[PATH_MAX];
size_t nr_worker_threads;
char *accept_tags;
int rule_effect_interval_ms;
@@ -31,7 +33,6 @@ struct maat_options {
int gc_timeout_ms;
int deferred_load_on;
int log_level;
struct log_handle *logger;
enum data_source input_mode;
union {
struct source_iris_ctx iris_ctx;

View File

@@ -241,9 +241,13 @@ int maat_options_set_redis(struct maat_options *opts, const char *redis_ip,
return 0;
}
int maat_options_set_logger(struct maat_options *opts, void *logger)
int maat_options_set_logger_path(struct maat_options *opts, const char *log_path)
{
opts->logger = (struct log_handle *)logger;
if (NULL == opts || NULL == log_path || strlen(log_path) >= PATH_MAX) {
return -1;
}
memcpy(opts->log_path, log_path, strlen(log_path));
return 0;
}
@@ -330,8 +334,8 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
int garbage_gc_timeout_s = 0;
struct maat *maat_instance = ALLOC(struct maat, 1);
if (opts->logger != NULL) {
maat_instance->logger = opts->logger;
if (strlen(opts->log_path) != 0) {
maat_instance->logger = log_handle_create(opts->log_path, opts->log_level);
} else {
char log_path[1024] = {0};
if (strlen(maat_instance->instance_name) > 0) {

View File

@@ -205,6 +205,8 @@ void ex_container_free(void *schema, void *data)
if (NULL == data) {
return;
}
struct ex_container *ex_container = (struct ex_container *)data;
//TODO:
if (NULL == schema) {
@@ -214,7 +216,7 @@ void ex_container_free(void *schema, void *data)
long argl = container_schema->ex_schema->argl;
void *argp = container_schema->ex_schema->argp;
struct ex_container *ex_container = (struct ex_container *)data;
if (ex_container->ex_data != NULL
&& container_schema->ex_schema->free_func != NULL) {
container_schema->ex_schema->free_func(container_schema->table_id,