diff --git a/conf/doh/doh.conf b/conf/doh/doh.conf index b128f71..97b2173 100644 --- a/conf/doh/doh.conf +++ b/conf/doh/doh.conf @@ -1,27 +1,13 @@ [doh] -# default 1 enable=1 -[log] -# default 10 -# RLOG_LV_DEBUG : 10 -# RLOG_LV_INFO : 20 -# RLOG_LV_FATAL : 30 -log_level=10 - [maat] -# default TSG_OBJ_APP_ID table_appid=TSG_OBJ_APP_ID -# default TSG_SECURITY_ADDR table_addr=TSG_SECURITY_ADDR -# default TSG_FIELD_DOH_QNAME table_qname=TSG_FIELD_DOH_QNAME -# default TSG_FIELD_HTTP_HOST table_host=TSG_FIELD_DOH_HOST [kafka] -# default 0 ENTRANCE_ID=0 -# default 1 # if enable "en_sendlog", the iterm "tfe.conf [kafka] enable" must set 1 en_sendlog=1 \ No newline at end of file diff --git a/conf/pangu/pangu_pxy.conf b/conf/pangu/pangu_pxy.conf index 94663df..600403d 100644 --- a/conf/pangu/pangu_pxy.conf +++ b/conf/pangu/pangu_pxy.conf @@ -1,5 +1,4 @@ [debug] -log_level=10 enable_plugin=1 [log] diff --git a/conf/tfe/tfe.conf b/conf/tfe/tfe.conf index f901274..d7ceb32 100644 --- a/conf/tfe/tfe.conf +++ b/conf/tfe/tfe.conf @@ -125,10 +125,6 @@ tcp_user_timeout=600 tcp_ttl_upstream=75 tcp_ttl_downstream=70 -[log] -level=10 -location=log/tfe.log - [stat] statsd_server=192.168.10.72 statsd_port=8126 @@ -137,9 +133,6 @@ statsd_cycle=5 statsd_format=2 histogram_bins=0.5,0.8,0.9,0.95 -[http] -loglevel=20 - [traffic_mirror] enable=1 device=eth4 diff --git a/conf/tfe/zlog.conf b/conf/tfe/zlog.conf new file mode 100644 index 0000000..70e3f72 --- /dev/null +++ b/conf/tfe/zlog.conf @@ -0,0 +1,20 @@ +# kill -s SIGHUP "pid" + +[global] + +default format = "%d(%c), %V, %F, %U, %m%n" + +[levels] + +DEBUG=10 +INFO=20 +FATAL=30 + +[rules] + +*.fatal "./log/error.log.%d(%F)"; +tfe.DEBUG "./log/tfe.log.%d(%F)"; +http.DEBUG "./log/http.log.%d(%F)"; +http2.DEBUG "./log/http2.log.%d(%F)"; +doh.DEBUG "./log/doh_pxy.log.%d(%F)"; +pangu.DEBUG "./log/pangu_pxy.log.%d(%F)"; \ No newline at end of file diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index 0d82243..188ad28 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -239,7 +239,10 @@ static void __signal_handler_cb(evutil_socket_t fd, short what, void * arg) { case SIGTERM: case SIGQUIT: - case SIGHUP: break; + case SIGHUP: + TFE_LOG_ERROR(ctx->logger, "recv SIGHUP, reload zlog.conf"); + MESA_handle_runtime_log_reconstruction(NULL); + break; case SIGUSR1: break; case SIGPIPE: TFE_PROXY_STAT_INCREASE(STAT_SIGPIPE, 1); @@ -724,6 +727,7 @@ int main(int argc, char * argv[]) { const char * main_profile = "./conf/tfe/tfe.conf"; const char * future_profile= "./conf/tfe/future.conf"; + const char * zlog_profile = "./conf/tfe/zlog.conf"; int ret = 0; int opt = 0; @@ -749,22 +753,23 @@ int main(int argc, char * argv[]) fprintf(stderr, "Tango Frontend Engine, Version: %s", __tfe_version); + if (0 != MESA_handle_runtime_log_creation(zlog_profile)) + { + fprintf(stderr, "MESA_handle_runtime_log_creation return error\n"); + exit(EXIT_FAILURE); + } + /* adds locking, only required if accessed from separate threads */ evthread_use_pthreads(); - unsigned int __log_level = RLOG_LV_INFO; - MESA_load_profile_uint_def(main_profile, "log", "level", &__log_level, RLOG_LV_INFO); - char __log_path[TFE_STRING_MAX]= {}; - MESA_load_profile_string_def(main_profile, "log", "location", __log_path, sizeof(__log_path), "log/tfe.log"); - - g_default_logger = MESA_create_runtime_log_handle(__log_path, __log_level); - if (unlikely(g_default_logger == NULL)) + g_default_logger = MESA_create_runtime_log_handle("tfe", RLOG_LV_DEBUG); + if (unlikely(g_default_logger == NULL)) { TFE_LOG_ERROR(g_default_logger, "Failed at creating default logger: %s", "log/tfe.log"); exit(EXIT_FAILURE); } - /* PROXY INSTANCE */ + /* PROXY INSTANCE */ g_default_proxy = ALLOC(struct tfe_proxy, 1); assert(g_default_proxy); strcpy(g_default_proxy->name, "tfe3a"); diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp index 7b7fd64..dfc2eb3 100644 --- a/plugin/business/doh/src/doh.cpp +++ b/plugin/business/doh/src/doh.cpp @@ -578,7 +578,6 @@ int doh_on_init(struct tfe_proxy *proxy) assert(g_doh_conf); MESA_load_profile_int_def(profile, "doh", "enable", &(g_doh_conf->enable), 1); - MESA_load_profile_int_def(profile, "log", "log_level", &(g_doh_conf->local_level), 10); if (!g_doh_conf->enable) { @@ -588,7 +587,7 @@ int doh_on_init(struct tfe_proxy *proxy) TFE_LOG_INFO(NULL, "Doh enabled."); g_doh_conf->thread_num = tfe_proxy_get_work_thread_count(); - g_doh_conf->local_logger = MESA_create_runtime_log_handle("./log/doh_pxy.log", g_doh_conf->local_level); + g_doh_conf->local_logger = MESA_create_runtime_log_handle("doh", RLOG_LV_DEBUG); g_doh_conf->gc_evbase = tfe_proxy_get_gc_evbase(); g_doh_conf->fs_handle = tfe_proxy_get_fs_handle(); diff --git a/plugin/business/doh/src/pub.h b/plugin/business/doh/src/pub.h index f59367d..4a73f45 100644 --- a/plugin/business/doh/src/pub.h +++ b/plugin/business/doh/src/pub.h @@ -54,7 +54,6 @@ struct doh_conf int enable; int thread_num; - int local_level; void *local_logger; int entry_id; diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index 1dd8507..6fe7043 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -128,7 +128,6 @@ struct pangu_rt Maat_feather_t maat; struct pangu_logger * send_logger; void * local_logger; - int log_level; int thread_num; int scan_table_id[__SCAN_TABLE_MAX]; int plolicy_table_id[POLICY_PROFILE_TABLE_MAX]; @@ -843,8 +842,7 @@ error_out: int pangu_http_init(struct tfe_proxy * proxy) { - const char * profile_path = "./conf/pangu/pangu_pxy.conf"; - const char * logfile = "./log/pangu_pxy.log"; + const char * profile_path = "./conf/pangu/pangu_pxy.conf";; int temp=0; g_pangu_rt = ALLOC(struct pangu_rt, 1); @@ -857,10 +855,9 @@ int pangu_http_init(struct tfe_proxy * proxy) g_pangu_rt->thread_num = tfe_proxy_get_work_thread_count(); g_pangu_rt->gc_evbase=tfe_proxy_get_gc_evbase(); - MESA_load_profile_int_def(profile_path, "DEBUG", "LOG_LEVEL", &(g_pangu_rt->log_level), 0); - g_pangu_rt->local_logger = MESA_create_runtime_log_handle(logfile, g_pangu_rt->log_level); + g_pangu_rt->local_logger = MESA_create_runtime_log_handle("pangu", RLOG_LV_DEBUG); - g_pangu_rt->send_logger = pangu_log_handle_create(profile_path, "LOG", g_pangu_rt->local_logger); + g_pangu_rt->send_logger = pangu_log_handle_create(profile_path, "LOG", g_pangu_rt->local_logger); if (!g_pangu_rt->send_logger) { goto error_out; diff --git a/plugin/protocol/http/include/internal/http_common.h b/plugin/protocol/http/include/internal/http_common.h index fe38931..9adef8a 100644 --- a/plugin/protocol/http/include/internal/http_common.h +++ b/plugin/protocol/http/include/internal/http_common.h @@ -22,10 +22,6 @@ struct http_plugin struct event * gc_event_hs_private[TFE_THREAD_MAX]; /* ACCESS LOGGER */ void * logger; - /* LOGLEVE */ - int log_level; - /* LOGFILE */ - char log_file[TFE_STRING_MAX]; }; extern struct http_plugin * g_http_plugin; diff --git a/plugin/protocol/http/src/http_entry.cpp b/plugin/protocol/http/src/http_entry.cpp index 54804fb..463dc94 100644 --- a/plugin/protocol/http/src/http_entry.cpp +++ b/plugin/protocol/http/src/http_entry.cpp @@ -55,21 +55,11 @@ static void http_plugin_session_gc_cb(evutil_socket_t fd, short what, void * arg } } -#include -int http_plugin_config(struct tfe_proxy * proxy, struct http_plugin * ht_handle) -{ - MESA_load_profile_int_def("conf/tfe/tfe.conf", "http", "loglevel", &ht_handle->log_level, RLOG_LV_INFO); - MESA_load_profile_string_def("conf/tfe/tfe.conf", "http", "logfile", ht_handle->log_file, sizeof(ht_handle->log_file), "log/http.log"); - return 0; -} - int http_plugin_init(struct tfe_proxy * proxy) { unsigned int nr_work_thread = tfe_proxy_get_work_thread_count(); struct http_plugin * plugin_ctx = g_http_plugin; - http_plugin_config(proxy, plugin_ctx); - for (unsigned int thread_id = 0; thread_id < nr_work_thread; thread_id++) { #ifndef NDEBUG @@ -99,8 +89,8 @@ int http_plugin_init(struct tfe_proxy * proxy) plugin_ctx->gc_event_hs_private[thread_id] = gc_event; } - plugin_ctx->logger = MESA_create_runtime_log_handle(plugin_ctx->log_file, plugin_ctx->log_level); - assert(plugin_ctx->logger != NULL); + plugin_ctx->logger = MESA_create_runtime_log_handle("http", RLOG_LV_DEBUG); + assert(plugin_ctx->logger != NULL); return 0; } diff --git a/plugin/protocol/http2/include/internal/http2_common.h b/plugin/protocol/http2/include/internal/http2_common.h index 8c048a8..18a8d7d 100644 --- a/plugin/protocol/http2/include/internal/http2_common.h +++ b/plugin/protocol/http2/include/internal/http2_common.h @@ -15,10 +15,6 @@ #include typedef struct RTLogInit2Data_ { - int run_log_level; - - char run_log_path[256]; - void *handle; } RTLogInit2Data; diff --git a/plugin/protocol/http2/src/http2_common.cpp b/plugin/protocol/http2/src/http2_common.cpp index 8135c4c..de18eaf 100644 --- a/plugin/protocol/http2/src/http2_common.cpp +++ b/plugin/protocol/http2/src/http2_common.cpp @@ -18,7 +18,7 @@ #include RTLogInit2Data logging_sc_lid = { - .run_log_level = 1, + }; RTLogInit2Data *logger() diff --git a/plugin/protocol/http2/src/http2_plugin.cpp b/plugin/protocol/http2/src/http2_plugin.cpp index 24caa62..699ff7a 100644 --- a/plugin/protocol/http2/src/http2_plugin.cpp +++ b/plugin/protocol/http2/src/http2_plugin.cpp @@ -46,13 +46,7 @@ struct event_timer_ctx void load_logging_conf(const char *config) { RTLogInit2Data *logging_sc_lid = logger(); - - MESA_load_profile_int_def(config, (const char *)"http",(const char *)"loglevel", - &logging_sc_lid->run_log_level, 10); - MESA_load_profile_string_def(config, (const char *)"http",(const char *)"logfile", - logging_sc_lid->run_log_path, 128, "log/http2.log"); - - logging_sc_lid->handle = MESA_create_runtime_log_handle(logging_sc_lid->run_log_path, logging_sc_lid->run_log_level); + logging_sc_lid->handle = MESA_create_runtime_log_handle("http2", RLOG_LV_DEBUG); if(logging_sc_lid->handle == NULL){ TFE_LOG_ERROR(logging_sc_lid->handle, "Create log runtime_log_handle error, init failed!"); }