diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index a56dbaa..11abdef 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -99,7 +99,7 @@ struct pangu_rt * g_pangu_rt; #define MAAT_INPUT_REDIS 1 #define MAAT_INPUT_FILE 2 -static Maat_feather_t create_maat_feather(const char * profile, const char * section, int max_thread, void * logger) +static Maat_feather_t create_maat_feather(const char * instance_name, const char * profile, const char * section, int max_thread, void * logger) { Maat_feather_t target; int input_mode = 0, maat_stat_on = 0, maat_perf_on = 0; @@ -111,7 +111,6 @@ static Maat_feather_t create_maat_feather(const char * profile, const char * sec int redis_port_select=0; int redis_db_idx = 0; char json_cfg_file[TFE_STRING_MAX] = {0}, maat_stat_file[TFE_STRING_MAX] = {0}; - const char * instance_name = "pangu"; MESA_load_profile_int_def(profile, section, "MAAT_INPUT_MODE", &(input_mode), 0); MESA_load_profile_int_def(profile, section, "STAT_SWITCH", &(maat_stat_on), 1); MESA_load_profile_int_def(profile, section, "PERF_SWITCH", &(maat_perf_on), 1); @@ -145,7 +144,7 @@ static Maat_feather_t create_maat_feather(const char * profile, const char * sec MESA_load_profile_int_def(profile, section, "EFFECT_INTERVAL_S", &(effect_interval), 60); effect_interval *= 1000;//convert s to ms - assert(strlen(inc_cfg_dir) != 0 && strlen(ful_cfg_dir) != 0); + assert(strlen(inc_cfg_dir) != 0 || strlen(ful_cfg_dir) != 0 || strlen(redis_server)!=0 || strlen(json_cfg_file)!=0); target = Maat_feather(max_thread, table_info, logger); Maat_set_feather_opt(target, MAAT_OPT_INSTANCE_NAME, instance_name, strlen(instance_name) + 1); @@ -364,15 +363,18 @@ void subscribe_id_new_cb(int table_id, const char* key, const char* table_line, size_t subscribe_id_offset, len; ret=get_column_pos(table_line, 7, &subscribe_id_offset, &len); if(ret<0) - { + { + TFE_LOG_ERROR(g_pangu_rt->local_logger, "Add subscribe ID faild: %s", table_line); return; - } + } *ad=ALLOC(char, len+1); - memcpy(*ad, table_line+subscribe_id_offset, len); + memcpy(*ad, table_line+subscribe_id_offset, len); + TFE_LOG_INFO(g_pangu_rt->local_logger, "Add subscribe ID: %s", (char*)*ad); return; } void subscribe_id_free_cb(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp) { + TFE_LOG_INFO(g_pangu_rt->local_logger, "Delete subscribe ID: %s", (char*)*ad); free(*ad); *ad=NULL; } @@ -398,7 +400,7 @@ int pangu_http_init(struct tfe_proxy * proxy) - g_pangu_rt->maat = create_maat_feather(profile, "MAAT", g_pangu_rt->thread_num, g_pangu_rt->local_logger); + g_pangu_rt->maat = create_maat_feather("static", profile, "MAAT", g_pangu_rt->thread_num, g_pangu_rt->local_logger); if (!g_pangu_rt->maat) { goto error_out; @@ -445,12 +447,12 @@ int pangu_http_init(struct tfe_proxy * proxy) trusted_CA_update_finish_cb, g_pangu_rt); - g_pangu_rt->dyn_maat = create_maat_feather(profile, "DYNAMIC_MAAT", g_pangu_rt->thread_num, g_pangu_rt->local_logger); + g_pangu_rt->dyn_maat = create_maat_feather("dyn", profile, "DYNAMIC_MAAT", g_pangu_rt->thread_num, g_pangu_rt->local_logger); if (!g_pangu_rt->maat) { goto error_out; } - g_pangu_rt->subscribe_id_table_id=Maat_table_register(g_pangu_rt->dyn_maat, "IPD_DYN_SUBSCIBE_IP"); + g_pangu_rt->subscribe_id_table_id=Maat_table_register(g_pangu_rt->dyn_maat, "IPD_DYN_SUBSCRIBE_IP"); temp=Maat_plugin_EX_register(g_pangu_rt->dyn_maat, g_pangu_rt->subscribe_id_table_id, subscribe_id_new_cb, @@ -1474,7 +1476,7 @@ void pangu_on_http_end(const struct tfe_stream * stream, if (ctx->action != PG_ACTION_NONE&& !(ctx->action == PG_ACTION_REPLACE && ctx->n_enforce==1 && ctx->rep_ctx->actually_replaced==0)) { ret=pangu_send_log(g_pangu_rt->send_logger, &log_msg); - ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_LOG_NUM]), ret); + ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_LOG_NUM]), ret); } if(ctx->rep_ctx && ctx->rep_ctx->actually_replaced==0) { diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp index 4b60fa1..aead470 100644 --- a/plugin/business/pangu-http/src/pangu_logger.cpp +++ b/plugin/business/pangu-http/src/pangu_logger.cpp @@ -217,6 +217,12 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) } for(size_t i=0; iresult_num; i++) { + + TFE_LOG_DEBUG(handle->local_logger, "URL: %s , hit cfg_id: %d service: %d", + http->req->req_spec.url, + log_msg->result[i].config_id, + log_msg->result[i].service_id); + if(log_msg->result[i].do_log==0) { continue; diff --git a/resource/pangu/dynamic_maat_table_info.conf b/resource/pangu/dynamic_maat_table_info.conf index 491b4bf..56f95e5 100644 --- a/resource/pangu/dynamic_maat_table_info.conf +++ b/resource/pangu/dynamic_maat_table_info.conf @@ -16,4 +16,4 @@ #For expr/expr_plus Table #id name type src_charset dst_charset do_merge cross_cache quick_mode -1 IPD_DYN_SUBSCIBE_IP plugin {"key":4,"valid":9} \ No newline at end of file +1 IPD_DYN_SUBSCRIBE_IP plugin {"key":4,"valid":9}