输出非结构化日志。
This commit is contained in:
@@ -90,8 +90,9 @@ struct pangu_rt
|
||||
int fs_id[__PG_STAT_MAX];
|
||||
struct event_base* gc_evbase;
|
||||
struct event* gcev;
|
||||
|
||||
|
||||
int ca_store_reseting;
|
||||
|
||||
};
|
||||
struct pangu_rt * g_pangu_rt;
|
||||
|
||||
@@ -502,7 +503,6 @@ int pangu_http_init(struct tfe_proxy * proxy)
|
||||
}
|
||||
TFE_LOG_INFO(NULL, "Tango Cache Enabled.");
|
||||
}
|
||||
|
||||
TFE_LOG_INFO(NULL, "Pangu HTTP init success.");
|
||||
return 0;
|
||||
|
||||
@@ -532,6 +532,7 @@ struct pangu_http_ctx
|
||||
struct Maat_rule_t * enforce_rules;
|
||||
size_t n_enforce;
|
||||
char * enforce_para;
|
||||
struct evbuffer* log_req_body, *log_resp_body;
|
||||
|
||||
struct replace_ctx * rep_ctx;
|
||||
|
||||
@@ -547,6 +548,7 @@ struct pangu_http_ctx
|
||||
size_t cache_result_declared_sz, cache_result_actual_sz;
|
||||
struct cache_write_context* cache_write_ctx;
|
||||
int cache_wirte_result;
|
||||
|
||||
int thread_id;
|
||||
};
|
||||
|
||||
@@ -628,7 +630,16 @@ static void pangu_http_ctx_free(struct pangu_http_ctx * ctx)
|
||||
future_destroy(ctx->f_cache_pending);
|
||||
ctx->f_cache_pending=NULL;
|
||||
}
|
||||
|
||||
if(ctx->log_req_body)
|
||||
{
|
||||
evbuffer_free(ctx->log_req_body);
|
||||
ctx->log_req_body=NULL;
|
||||
}
|
||||
if(ctx->log_resp_body)
|
||||
{
|
||||
evbuffer_free(ctx->log_resp_body);
|
||||
ctx->log_resp_body=NULL;
|
||||
}
|
||||
ctx->magic_num=0;
|
||||
FREE(&ctx);
|
||||
}
|
||||
@@ -1141,6 +1152,25 @@ void enforce_control_policy(const struct tfe_stream * stream, const struct tfe_h
|
||||
default: assert(0);
|
||||
break;
|
||||
}
|
||||
if(ctx->action!=PG_ACTION_NONE && ctx->action!=PG_ACTION_WHITELIST)
|
||||
{
|
||||
if (events & EV_HTTP_REQ_BODY_BEGIN)
|
||||
{
|
||||
ctx->log_req_body=evbuffer_new();
|
||||
}
|
||||
if (events & EV_HTTP_RESP_BODY_BEGIN)
|
||||
{
|
||||
ctx->log_resp_body=evbuffer_new();
|
||||
}
|
||||
if(events & EV_HTTP_REQ_BODY_CONT)
|
||||
{
|
||||
evbuffer_add(ctx->log_req_body, body_frag, frag_size);
|
||||
}
|
||||
if(events & EV_HTTP_RESP_BODY_CONT)
|
||||
{
|
||||
evbuffer_add(ctx->log_resp_body, body_frag, frag_size);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#define RESUMED_CB_NO_MORE_CALLS 0
|
||||
@@ -1478,7 +1508,8 @@ void pangu_on_http_end(const struct tfe_stream * stream,
|
||||
FREE(&(ctx->enforce_rules));
|
||||
}
|
||||
}
|
||||
struct pangu_log log_msg = {.stream=stream, .http=session, .result=ctx->enforce_rules, .result_num=ctx->n_enforce};
|
||||
struct pangu_log log_msg = {.stream=stream, .http=session, .result=ctx->enforce_rules, .result_num=ctx->n_enforce,
|
||||
.req_body= ctx->log_req_body, .resp_body=ctx->log_resp_body};
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user