diff options
| author | luqiuwen <[email protected]> | 2018-12-13 23:40:36 +0600 |
|---|---|---|
| committer | luqiuwen <[email protected]> | 2018-12-13 23:40:36 +0600 |
| commit | 8c93f7203d7c2d4a6d3b7809249273cf555d4e22 (patch) | |
| tree | a02e33464538fab5e8b74c4951d2d056469af043 | |
| parent | 94242de81c01e592a44d48ab17c9b96ced6d713b (diff) | |
增加HTTP日志等级配置功能
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | plugin/protocol/http/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | plugin/protocol/http/include/internal/http_common.h | 4 | ||||
| -rw-r--r-- | plugin/protocol/http/src/http_entry.cpp | 12 |
4 files changed, 17 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f1ae17..f8c26b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ option(ENABLE_SANITIZE_THREAD "Enable ThreadSanitizer" FALSE) # Plugins option(ENABLE_PLUGIN_HTTP "Enable HTTP support" TRUE) -option(ENABLE_PLUGIN_DECRYPT_MIRRORING "Enable decrypt mirroring" FALSE) +option(ENABLE_PLUGIN_DECRYPT_MIRRORING "Enable decrypt mirroring" TRUE) option(ENABLE_PLUGIN_PANGU_HTTP "Enable Pangu-HTTP business" TRUE) if(ENABLE_PIC) diff --git a/plugin/protocol/http/CMakeLists.txt b/plugin/protocol/http/CMakeLists.txt index b85e894..2dc0054 100644 --- a/plugin/protocol/http/CMakeLists.txt +++ b/plugin/protocol/http/CMakeLists.txt @@ -9,6 +9,7 @@ target_link_libraries(http http-parser-static) target_link_libraries(http libevent-static) target_link_libraries(http z) target_link_libraries(http brotlienc-static brotlidec-static) +target_link_libraries(http MESA_prof_load) ### UNITTEST CASE add_executable(test-http-half test/test_http_half.cpp) diff --git a/plugin/protocol/http/include/internal/http_common.h b/plugin/protocol/http/include/internal/http_common.h index 9adef8a..fe38931 100644 --- a/plugin/protocol/http/include/internal/http_common.h +++ b/plugin/protocol/http/include/internal/http_common.h @@ -22,6 +22,10 @@ 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 108a174..7dd5277 100644 --- a/plugin/protocol/http/src/http_entry.cpp +++ b/plugin/protocol/http/src/http_entry.cpp @@ -55,11 +55,21 @@ static void http_plugin_session_gc_cb(evutil_socket_t fd, short what, void * arg } } +#include <MESA/MESA_prof_load.h> +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 @@ -89,7 +99,7 @@ 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("log/http.log", RLOG_LV_INFO); + plugin_ctx->logger = MESA_create_runtime_log_handle(plugin_ctx->log_file, plugin_ctx->log_level); assert(plugin_ctx->logger != NULL); return 0; |
