修改日志字段common_service_category为数组格式
This commit is contained in:
@@ -81,14 +81,11 @@ error_out:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pangu_log_get_fqdn_cat(struct tfe_cmsg *cmsg, char *fqdn_cat_buff)
|
static unsigned int pangu_log_get_fqdn_cat(struct tfe_cmsg *cmsg, unsigned int *category_id_val)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
unsigned int i=0, category_id_num=0;
|
unsigned category_id_num=0;
|
||||||
uint16_t opt_out_size;
|
uint16_t opt_out_size;
|
||||||
unsigned int category_id_val[TFE_SYMBOL_MAX]={0};
|
|
||||||
|
|
||||||
char *p = fqdn_cat_buff;
|
|
||||||
|
|
||||||
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_FQDN_CAT_ID_NUM, (unsigned char *)&category_id_num, sizeof(category_id_num), &opt_out_size);
|
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_FQDN_CAT_ID_NUM, (unsigned char *)&category_id_num, sizeof(category_id_num), &opt_out_size);
|
||||||
if (ret != 0 || category_id_num == 0)
|
if (ret != 0 || category_id_num == 0)
|
||||||
@@ -101,12 +98,7 @@ static int pangu_log_get_fqdn_cat(struct tfe_cmsg *cmsg, char *fqdn_cat_buff)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < category_id_num && i < 8; i++)
|
return category_id_num > 8 ? 8 : category_id_num;
|
||||||
{
|
|
||||||
p += snprintf(p, sizeof(fqdn_cat_buff) - (p - fqdn_cat_buff), "%s%d", i>0 ? "," : "", category_id_val[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
|
int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
|
||||||
@@ -153,8 +145,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
|
|||||||
cJSON_AddStringToObject(common_obj, "http_version", app_proto[http->major_version]);
|
cJSON_AddStringToObject(common_obj, "http_version", app_proto[http->major_version]);
|
||||||
cJSON_AddStringToObject(common_obj, "common_schema_type", "HTTP");
|
cJSON_AddStringToObject(common_obj, "common_schema_type", "HTTP");
|
||||||
|
|
||||||
unsigned int common_direction=0;
|
unsigned int common_direction=0, category_id_val[8]={0};
|
||||||
char category_id_val[TFE_SYMBOL_MAX];
|
|
||||||
char opt_val[24]={0}; uint16_t opt_out_size;
|
char opt_val[24]={0}; uint16_t opt_out_size;
|
||||||
struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(log_msg->stream);
|
struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(log_msg->stream);
|
||||||
if (cmsg!=NULL)
|
if (cmsg!=NULL)
|
||||||
@@ -170,9 +161,9 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
|
|||||||
cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0:域内->域外,1:域外->域内,描述的是CLIENT_IP信息
|
cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0:域内->域外,1:域外->域内,描述的是CLIENT_IP信息
|
||||||
}
|
}
|
||||||
ret = pangu_log_get_fqdn_cat(cmsg, category_id_val);
|
ret = pangu_log_get_fqdn_cat(cmsg, category_id_val);
|
||||||
if (ret==0)
|
if (ret>0)
|
||||||
{
|
{
|
||||||
cJSON_AddStringToObject(common_obj, "common_service_category", category_id_val);
|
cJSON_AddItemToObject(common_obj, "common_service_category", cJSON_CreateIntArray((const int*)category_id_val, ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user