From 1f24c96a9544e47d7bee6f1927741cb913d965bd Mon Sep 17 00:00:00 2001 From: liuxueli Date: Thu, 3 Jun 2021 13:49:12 +0800 Subject: [PATCH] =?UTF-8?q?common=5Fservice=5Fcategory=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=94=B1=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tsg_send_log.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp index 3fe7756..29779f6 100644 --- a/src/tsg_send_log.cpp +++ b/src/tsg_send_log.cpp @@ -286,18 +286,19 @@ static int set_duraction(struct tsg_log_instance_t *_instance, struct TLD_handle static int set_fqdn_category(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream, unsigned int *category_id, int category_id_num) { - int i=0,offset=0; - char category_str[128]={0}; - - for(i=0; i< category_id_num; i++) + int i=0; + if(category_id_num<=0 || category_id==NULL) { - offset+=snprintf(category_str+offset, sizeof(category_str)-offset, "%s%d", ((i>0) ? "," : ""), category_id[i]); + return 0; + } + + cJSON *fqdn_array=cJSON_CreateArray(); + for(i=0; iid2field[LOG_COMMON_FQDN_CATEGORY].name, category_id[i]); } - if(offset>0) - { - TLD_append(_handle, _instance->id2field[LOG_COMMON_FQDN_CATEGORY].name, (void *)category_str, TLD_TYPE_STRING); - } + cJSON_AddItemToObject(_handle->object, _instance->id2field[LOG_COMMON_FQDN_CATEGORY].name, fqdn_array); return 1; }